Wireless Cue Light Projectfall 2011
Download
Report
Transcript Wireless Cue Light Projectfall 2011
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.
Planning
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
1.
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.
Software used
Arduino
X-CTU (XBEE)
Fritzing
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
System
1 master cue light box to run remote cue
light boxes.
Master
Box C
Cue Box A
Cue Box B
Wiring Diagram for C; sending
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
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
}
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
}
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");
}
}
Wiring diagram for Unit A
Receiving
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
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
}
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
Lights ON!!
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.
Testing XBEE for operation
board#1 send unit
Attached to pc
Type H to turn on LED
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 to
int 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);
}
}
}
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); }