Serial a text depending on button switch

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
gosbrut
 
Posts: 74
Joined: Thu Feb 20, 2014 5:36 pm

Serial a text depending on button switch

Post by gosbrut »

Hello, i want a basic example for display text via serial A or B depending button press or not.
I follow the example of http://learn.adafruit.com/adafruit-ardu ... duino-code but with no results,


Image


FOLLOWING CODE

void setup() {
Serial.begin(9600);
pinMode(8, INPUT_PULLUP);
}

void loop(){
if (digitalRead(8)==HIGH){
Serial.println("A");
} else {
Serial.println("B");
}
delay(300);
}

Only displays "A" on serial monitor, why ? how to reach the A or B depending on button press ?

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

Re: Serial a text depending on button switch

Post by adafruit_support_bill »

You need to connect a wire from the other side of your button to GND on the Arduino.

gosbrut
 
Posts: 74
Joined: Thu Feb 20, 2014 5:36 pm

Re: Serial a text depending on button switch

Post by gosbrut »

Resolved using the following config:

Image

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

Return to “Other Products from Adafruit”