Top Banner
Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs
22

Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Mar 26, 2015

Download

Documents

Julian Leach
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs

Page 2: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Objective

Using arduino and xbee technology create a system of cue lights using a master controller to turn on and off LED lamps connected to a wireless receiver.

Page 3: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Planning

1. Obtain materials

2. Test ardiuno

3. Test xbee through serial port

4. Test xbee for wireless operation

5. Create system diagram

6. Design Unit C main control

7. Write program for unit C

8. Design Unit A wireless receiver

9. Write program for unit A

Page 4: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Planning continued

10. Set up unit C to control one LED on main board

11. Set up unit C and A test control of one LED

12. Analyze data

13. Set up unit C to control two LEDs’on main board

Set up unit C and A test control of Two LEDs.

Page 5: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Software used

Arduino X-CTU (XBEE) Fritzing

Page 6: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Hardware Used Arduino Arduino Shield Xbee Xbee modem 10K resistors SPSB 4 pin switch LED; 2 Blue, 2 green 1 -breadboard 2 -“AA” battery packs 6 volts per pack Misc breadboard wires

Page 7: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

System

1 master cue light box to run remote cue light boxes.

Page 8: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Wiring Diagram for C; sending

Page 9: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit C; defining variables //Board C sending version 3 //using push button to cue wireless LED //using combination of pushbutton program and serial program

//constants do not change Used to set pin numbers.

const int buttonPinR = 2; //the number of the Red Led button on board C const int LedPinR = 13; // the number of the Red LED pin const int buttonPinB = 3; //the number of ther Blue Led button on board C const int LedPinB = 12; //the number of the Blue Led pin

int valR = 0; //val will be stored the state of the input pin Red int valB = 0; //val will be stored the state of the input pin Blue int old_valR= 0;// this variable stores the previous value red int old_valB = 0; // this variable stores the previouse value blue int stateR = 0; //0=Led red off and 1= Led red on int stateB= 0; // 0= led blue off and 1= led blue on

Page 10: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit C; set-up void setup() { Serial.begin(9600);//talk to other units pinMode(LedPinR, OUTPUT);//initialize Red

Led as output pinMode (LedPinB, OUTPUT); // initial Blue

Led as output pinMode(buttonPinR, INPUT);//initalize button

Red as input pinMode(buttonPinB, INPUT); //initial button

Blue as output }

Page 11: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit C; program void loop(){ valR = digitalRead(buttonPinR); //read input value Red and store it valB = digitalRead(buttonPinB); //read input value Blue and store it if ((valR == HIGH) && (old_valR == LOW)){ stateR = 1-stateR; delay(10); }

if ((valB == HIGH) && (old_valB == LOW)){ stateB = 1-stateB; delay(10); //check if there was a transition }

Page 12: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit C; send old_valR = valR; //valR is now old store it. old_valB = valB; //valB is now old store it.

if (stateR == 1){ //turn led red on digitalWrite(LedPinR, HIGH); Serial.print ("R"); //I switched the messages so uppercase R and B are for red and blue on,

lowercase r and b is for red and blue off, single character messages make simpler } if (stateB == 1){ //turn led blue on digitalWrite(LedPinB, HIGH); Serial.print ("B"); } if (stateR == 0) { // turn LED off digitalWrite(LedPinR, LOW); Serial.print ("r"); } if (stateB == 0) { digitalWrite(LedPinB, LOW); Serial.print ("b"); } }

Page 13: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Wiring diagram for Unit A Receiving

Page 14: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit A; Receive; variables // recieving board "A" version 3

const int LedPinR = 13; // the number of the Red LED pin const int LedPinB = 12; //the number of the Blue Led pin

int incomingByte; //a variable to read incoming seril data into

//int val = 0; //val will be stored the state of the input pin Red //int valB = 0; //val will be stored the state of the input pin Blue //int old_valR= 0;// this variable stores the previous value red //int old_valB = 0; // this variable stores the previouse value blue //int stateR = 0; //0=Led red off and 1= Led red on //int stateB= 0; // 0= led blue off and 1= led blue on

Page 15: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit A; set-up

void setup() { Serial.begin(9600); pinMode(LedPinR, OUTPUT);//initialize

Red Led as output pinMode (LedPinB, OUTPUT); // initial

Blue Led as output }

Page 16: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Code For Unit A; program

void loop() { if (Serial.available()) { incomingByte = Serial.read(); Serial.println(incomingByte); delay(100); //valB = Serial.read(); //delay(100); if (incomingByte == 'R') { digitalWrite(LedPinR, HIGH); } if (incomingByte == 'r') { digitalWrite(LedPinR, LOW); } if (incomingByte == 'B') { digitalWrite(LedPinB, HIGH); } if (incomingByte == 'b') { digitalWrite(LedPinB, LOW); } } }

/* I changed it to use the incomingByte variable you already had setup and made it match the data being sent from the other board, using single characters for the messages makes everything simpler

Page 17: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Lights ON!!

Page 18: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.
Page 19: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Conclusion

Unit works. Circuits need to be made. Boxes designed to house units. Issues: About a 30 second wait for the LED’s to

turn on or off. Xbee configuration needs to be

researched.

Page 20: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Testing XBEE for operation board#1 send unit Attached to pc Type H to turn on LED

Page 21: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Program for send unit

/*  Physical Pixel  An example of using the Arduino board to receive data from the  computer.  In this case, the Arduino boards turns on an LED when it receives the character 'H', and turns off the LED when it receives the character 'L'.   The circuit: * LED connected from digital pin 13 to ground

const int ledPin = 13; // the pin that the LED is attached toint incomingByte;      // a variable to read incoming serial data into

void setup() {  // initialize serial communication:  Serial.begin(9600);  // initialize the LED pin as an output:  pinMode(ledPin, OUTPUT);}

void loop() {  // see if there's incoming serial data:  if (Serial.available() > 0) {    // read the oldest byte in the serial buffer:    incomingByte = Serial.read();    // if it's a capital H (ASCII 72), turn on the LED:    if (incomingByte == 'H') {      digitalWrite(ledPin, HIGH);    }     // if it's an L (ASCII 76) turn off the LED:    if (incomingByte == 'L') {      digitalWrite(ledPin, LOW);    }  }}

Page 22: Wireless Cue Light Project Sue Brandt Arduino Project 12-10-2010 Ins and Outs.

Testing XBEE for operation board #2 Receiver unit Second board programming

void setup() { Serial.begin(9600); } void loop() { Serial.print('H'); delay(1000); Serial.print('L'); delay(1000); }