Teensy Switch?

Not open for further replies.


New member
i have teensy 3.1

i want to know how i can switch two programs

i have switch connected to pin 0 witch i use as a input when de voltage is hight it changes to red but when i get voltage down they don't go to the initial state

any help?:D
There is a switch connected to pin 0 that sends a digital signal (1 or 0), that signal activates one loop or another. The code is very simple:

void setup (){
pinMode (0, INPUT);

void loop () {
if (digitalRead(0)){
else {

when i first turn on the switch and then digitalRead(0) is high, it works fine and starts the function modeRed(), but when i turn off the switch and therefore digitalRead(0) is back to low it keeps running the function modeRed() and never goes back to modeBlue().

I hope that's enough detail beacuse i don't know how to explain it better.
Thanks for helping :)
Probably best to start by copying an example. You'll need to understand what a circuit is and what a pullup or pulldown resistor is used for. There are many examples and tutorials on the web. Here's one other example that might be easier.
Not open for further replies.