20 unbelievable arduino projects

Page 188

File Downloads

FTPumpkin.pde (392 bytes) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'FTPumpkin.pde']

Step 14: Program the transmitter The transmitter is a little bit trickier if you are using a SquidBee setup because it is lacking an ATMEGA chip. First unplug the XBee shield. If necessary, add and bootload and the chip. Then, like the other board, change the power selection jumper to USB, and then upload the following code: /* Flamethrowing Jack-O'-Lantern Trigger code Based on Button example code http://www.arduino.cc/en/Tutorial/Button created 2005 by DojoDave <http://www.0j0.org> modified 28 Oct 2010 by Tom Igoe The circuit: * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 from ground This code is in the public domain. */ // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // variables will change: int buttonState = 0;

// variable for reading the pushbutton status

void setup() { // initialize serial communication: Serial.begin(9600); // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); //transmit a High command to the pumpkin and delay a second so that it does not recieve more than one command //per button press Serial.println('h'); delay(1000); } else { // turn LED off: digitalWrite(ledPin, LOW); }

http://www.instructables.com/id/20-Unbelievable-Arduino-Projects/


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.