Permalink
Browse files

Updates from weekend

  • Loading branch information...
tigoe committed Jul 19, 2011
1 parent 66a5ef5 commit ae53f617fe8206a70f650f781fcc3c122199487e
View
@@ -0,0 +1,40 @@
/*
Simple Serial
Context: Arduino
Listens for an incoming serial byte, adds one to the byte
and sends the result back out serially.
Also blinks an LED on pin 13 every half second.
*/
int LEDPin = 13; // you can use any digital I/O pin you want
int inByte = 0; // variable to hold incoming serial data
long blinkTimer = 0; // keeps track of how long since the LED
// was last turned off
int blinkInterval = 1000; // a full second from on to off to on again
void setup() {
pinMode(LEDPin, OUTPUT); // set pin 13 to be an output
Serial.begin(9600); // configure the serial port for 9600 bps
// data rate.
}
void loop() {
// if there are any incoming serial bytes available to read:
if (Serial.available() > 0) {
// then read the first available byte:
inByte = Serial.read();
// and add one to it, then send the result out:
Serial.write(inByte+1);
}
// Meanwhile, keep blinking the LED.
// after a half of a second, turn the LED on:
if (millis() - blinkTimer >= blinkInterval / 2) {
digitalWrite(LEDPin, HIGH); // turn the LED on pin 13 on
}
// after a half a second, turn the LED off and reset the timer:
if (millis() - blinkTimer >= blinkInterval) {
digitalWrite(LEDPin, LOW); // turn the LED off
blinkTimer = millis(); // reset the timer
}
}
@@ -0,0 +1,15 @@
void setup() {
Serial.begin(9600); // open serial communications
pinMode(2, INPUT); // make pin 2 an input
pinMode(3, INPUT); // make pin 3 an input
}
void loop() {
int roundButton = digitalRead(2); // read pin 2
int squareButton = digitalRead(3); // read pin 3
Serial.print("round: " ); // print out:
Serial.print(roundButton); // pin 2
Serial.print(" square: " );
Serial.println(squareButton); // pin 3
}
@@ -0,0 +1 @@
mode=Android
@@ -51,8 +51,9 @@ void loop() {
if (inByte >= '0' && inByte <= '9') {
// map the incoming byte value to the range of the analogRead() command:
brightness = map(inByte, '0', '9', 0, 255);
// set the current pin to the current brightness:
analogWrite(currentPin, brightness);
}
// set the current pin to the current brightness:
analogWrite(currentPin, brightness);
}
}
@@ -23,22 +23,22 @@
if (isset($name) && isset($age) ) {
if ($age < 21) {
echo <p> $name, Youre not old enough to drink.</p>\n;
echo "<p> $name, You're not old enough to drink.</p>\n";
} else {
echo <p> Hi $name. Youre old enough to have a drink, but do ;
echo so responsibly.</p>\n;
echo "<p> Hi $name. You're old enough to have a drink, but do ";
echo "so responsibly.</p>\n";
}
}
?>
<html>
<body>
<form action=age_checker.php method=post
enctype=application/x-www-form-urlencoded>
First name: <input type=text name=name /><br>
Last name: <input type=age name=age />
<input type=submit value=Submit />
<form action="age_checker.php" method="post"
enctype="application/x-www-form-urlencoded">
Name: <input type="text" name="name" /><br>
Age: <input type="age" name="age" />
<input type="submit" value="Submit" />
</form>
</body>

0 comments on commit ae53f61

Please sign in to comment.