I need to find the CODE to program PIN: D10 to be a constant pulse. And CHANGE color (ONLY white/blue/purple/red/orange/yellow/white) every 15 seconds (at 128bpm or 4/8th count) to stay with the beat. SO I need to control the speed of the pulse AND I need it to scroll through the colors ever 15 seconds.
For the timekeeping, you should get familiar with the millis() function: http://arduino.cc/en/reference/millis
128bpm is approximately one beat every 469 milliseconds. I'd get the timing and pulsing worked out first before you start tackling the color changes.
I have added a on/on button to the firewalker project so I can turn on and off the the pressure sensor and then activate the color scroll. the PROBLEM I have is that I need to add the color roll script to the firewalker script to make THE GIRL ON FIRE BOOTS!
So the Color Roll Script works on Floras D10 terminal. and the Firewalker script works on D6 terminal. How do I combine the into one script?
The FireWalker code already has the pin and the strip defined, it also handles the strip.begin(), so you don't need to repeat any of that. All you need is the code from your Color Roll loop. The simplet way to do that is to copy your entire loop function and paste it at the end of the FireWalker Code. Then change the name of "loop()" to "ColorRoll()".
But before you can integrate it with the FireWalker code, you need to do is write down exactly what you have and how you want it to work. Before you can write the code to switch between modes you need to define:
What pin or pins are your switches wired to?
How are your switches wired?
What do you want to happen when you press each switch?
1. When you power the boots on it is in the "mode" the switch was last on or open to.
2. MODE 1 is firewalker mode. wired from the NeoPixel strip to the center pin (#2) of the switch. Out the left pin (#1) to D6 on the flora board (as in the normal setup).
3. MODE 2 is Color Roll mode (since I could not find a plus code I modified one). The right pin (#3) is wired to D10
When I load one code it works on one side of the on/on button. and the other side with the other code.
NOTE: I originally changed the "Firewalker" code to have the lights stay on when the pressure sensor is not active. I was trying to get the "pulse" go there if possible.
Ok so I was able to add and verify the two sketches in to one. The "Firewalker" part still works, But the "Color_Roll" (to be correct the Sketch is named ColorWhipe) does not work. Once again they work separately loaded on Flora on the separate terminals to the button. I have attached the code for review.
Instead of switching the data pin, you should switch the modes in software.
Connect the center pin of your switch to ground.
Then connect the other two pins of the switch to digital pins on the Flora.
Set the pinMode of your switch pins to INPUT_PULLUP. http://arduino.cc/en/Reference/pinMode
if (digitalRead(mode1Pin) == LOW)
{
// do mode1 pattern
}
else if (digitalRead(mode2Pin) == LOW)
{
// do mode2 pattern
}
Note that the patterns will take some time to run, so the mode switch will not be immediate. It will only switch after the previous pattern has run to completion.
int ledPin = 10; // LED connected to digital pin 10
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
int ledPin = 12; // LED connected to digital pin 12
void setup()
{
pinMode(ledPin, INPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
if (digitalRead(Pin D10) == LOW)
{
// do mode1 ColorWipe pattern
}
else if (digitalRead(pin D12) == LOW)
{
// do mode2 Firewalker pattern
}
Last edited by adafruit_support_bill on Mon Dec 15, 2014 7:19 pm, edited 2 times in total.
Reason:Pasted the code in-line
Where did that code come from? I thought you were starting with Firewalker code? And what happened to your colorRoll code? Neopixels are not programmed like regular LEDs, you cant just set the ledpin HIGH or LOW. You need to use the neopixel library.
You can only have one setup() one loop() and one variable called ledPin. Please follow the instructions in my previous post:
The FireWalker code already has the pin and the strip defined, it also handles the strip.begin(), so you don't need to repeat any of that. All you need is the code from your Color Roll loop. The simplest way to do that is to copy your entire loop function and paste it at the end of the FireWalker Code. Then change the name of "loop()" to "ColorRoll()".
OK i did add the "colorWipe" sketch to the Firewalker, and it is verified.
if I change "void loop()" to "void colorWipe" it gives me the error:
core.a(main.cpp.o): In function `main':
/Users/MrLojo/Desktop/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/hardware/arduino/cores/arduino/main.cpp:14: undefined reference to `loop'
Somehow you deleted the original lop. If you copy the loop() from your colorRoll code to the end of the FireWalker code as I instructed, you will have 2 loop() functions. Rename the one from your colorRoll code to colorRoll(). You will still have the original FireWalker loop() and will not get that error message.