Hi all!
This is my first post...for my first problem with teensy! I am totally new to this world...so I am sure that I am missing something simple...but I don't know what!
I have a Teensy 2.0, what I am trying to do is connect a pushbutton to teensy and when the button is pressed the built-in led should turn on.
Code (I am using Teensyduino)
I tried to rotate the pushbutton, but not work. The led never turn on.
I am start thinking that my teensy is broken....
Anyone can explain me what is wrong?
Thanks to all!
This is my first post...for my first problem with teensy! I am totally new to this world...so I am sure that I am missing something simple...but I don't know what!
I have a Teensy 2.0, what I am trying to do is connect a pushbutton to teensy and when the button is pressed the built-in led should turn on.
Code (I am using Teensyduino)
Code:
void setup()
{
pinMode(PIN_D6, OUTPUT); // LED
pinMode(PIN_B0, INPUT_PULLUP); // Pushbutton
}
void loop()
{
if ( digitalRead(PIN_B0) == LOW ) { //Button is pressed?
digitalWrite(PIN_D6, HIGH); // LED on
} else {
digitalWrite(PIN_D6, LOW); // LED off
}
}
I tried to rotate the pushbutton, but not work. The led never turn on.
I am start thinking that my teensy is broken....
Anyone can explain me what is wrong?
Thanks to all!