/* Andrew Anselmo Clipboard Engineering Test code for Arduino+XBee base unit. Four bits are toggled on and off every 250 ms (20 Hz); (bits 2-5); they are hooked up to the Arduino XBee inputs 0-4. Note that a resistor divider must be used; the Arduino UNO uses 0-5 V, and the XBee uses 0-3.3 V. */ int led = 13; int i; int output_pins[4]={2,3,4,5}; void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); // simple /* for(i=0;i<=3;i++) { pinMode(output_pins[i],OUTPUT); } */ // output bits DDRD = DDRD | B11111100; } // the loop routine runs over and over again forever: void loop() { // simple; not simultaneous enough! // This 50 ms on/50 ms off; this is 10 Hz /* for(i=0;i<=3;i++) { digitalWrite(output_pins[i],HIGH); } digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(50); // wait for 50 ms for(i=0;i<=3;i++) { digitalWrite(output_pins[i],LOW); } digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(50); // wait for 50 ms */ // simultaneous is nicer; all bits go on and off at the same time. // on-off cycle is 500 ms, 20 Hz // B76543210 PORTD = B00111100; delay(250); // B76543210 PORTD = B00000000; delay(250); }