EL Wire Light-Up Dog Harness
Contributors:
jenfoxbot
Programming
Now it's time to program the electronics.
Connect EL Sequencer to computer via 5V FTDI BOB or cable.
Program the EL Sequencer using the Arduino platform; the EL Sequencer runs an ATmega 328p at 8 MHz and 3.3V.
Write a program to read in the analog value of the ambient light sensor, turn on the appropriate EL wire channels at a value that corresponds to low light, and turn off once the light sensor value is above the low light threshold.
Below is a sample Arduino sketch with a preset light threshold:
// EL Wire Dog Harness Program // Turn EL wire on when ambient light is low. // JenFoxBot // Based on test sketch by Mike Grusin, SparkFun Electronics void setup() { Serial.begin(9600); // The EL channels are on pins 2 through 9 // Initialize the pins as outputs pinMode(2, OUTPUT); // channel A pinMode(3, OUTPUT); // channel B pinMode(4, OUTPUT); // channel C pinMode(5, OUTPUT); // channel D pinMode(6, OUTPUT); // channel E pinMode(7, OUTPUT); // channel F pinMode(8, OUTPUT); // channel G pinMode(9, OUTPUT); // channel H // We also have two status LEDs, pin 10 on the Escudo, // and pin 13 on the Arduino itself pinMode(10, OUTPUT); pinMode(13, OUTPUT); pinMode(A2, INPUT); } void loop() { int x,status; //If ambient lighting is too low, turn on EL wire if(analogRead(A2) < 50){ digitalWrite(2, HIGH); //turn EL channel on delay(1000); //wait 1 second //Keep EL wire on until light sensor reading is greater than 50 if(analogRead(A2) > 50){ digitalWrite(2, LOW); //turn EL channel off delay(10); } Serial.println(analogRead(A2)); // Use this to check value of ambient light digitalWrite(10, status); // blink both status LEDs digitalWrite(13, status); } }
Check that the EL wire turns on when the ambient light is low and turns off in bright light.