Firewalker Mode button

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

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.
We don't have any examples that do that specifically. Lesson 6 covers the basics of wiring and programming switches for digital inputs: https://learn.adafruit.com/adafruit-ard ... tal-inputs

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.

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

UPDATE:

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?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

the Color Roll Script works on Floras D10 terminal
Which script is that? Do you have a link to it?

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

All I did was change the Adafruit_NeoPixel strandtest #definepin from PIN 6 to PIN 10.

NOW how do I add this to the Firewalker code?
Attachments
Original Code
Original Code
Screenshot 2014-12-14 11.07.38.png (68.89 KiB) Viewed 274 times
Color_Roll at 128BPM
Color_Roll at 128BPM
Screenshot 2014-12-14 11.04.28.png (33.51 KiB) Viewed 275 times

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

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?

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

OK

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.
Attachments
Slide1.jpg
Slide1.jpg (102.07 KiB) Viewed 270 times

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

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.

https://www.dropbox.com/s/o3ch67294s4jx ... 3.ino?dl=0

Like I said press the button and to open the D10 terminal get the ColorWhipe.

Press the button again get the Firewalker on pressure sensor.

Tell me what I did wrong.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

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

Now in you code, you can write something like:

Code: Select all

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.

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

where in the code would be the best place to put the code? at the end? begining? after the first code?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

The pinMode() call goes in your setup. The if/else statement goes in your loop.

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

OK this is what i have done.

I took the first sketch and duplicated it for both pins. < got an error that the second part was a "redefine of 'int ledPin'".

I also added the "mode" code to the end of it. but where do i define the "do mode# pattern"?

https://www.dropbox.com/s/nkm4pf39sgytu ... h.ino?dl=0

Then where do i stick this.

Code: Select all


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

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

ok I am getting a bunch of errors. can you just skype me? Mr.Lojo

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

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()".

User avatar
MrLojo
 
Posts: 30
Joined: Thu Dec 11, 2014 5:46 am

Re: Firewalker Mode button

Post by MrLojo »

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'

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker Mode button

Post by adafruit_support_bill »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”