100% found this document useful (1 vote)
153 views8 pages

Responder Experiment V2.0

This document provides an overview, specification, hardware requirements, connection diagrams, sample code, and example picture for a three button responder experiment using an Arduino UNO. The experiment uses four buttons, three LEDs, resistors, a breadboard, jumper wires, and a USB cable. Pressing each button will illuminate the corresponding LED until the reset button is pressed, at which point all LEDs will turn off.

Uploaded by

pr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
153 views8 pages

Responder Experiment V2.0

This document provides an overview, specification, hardware requirements, connection diagrams, sample code, and example picture for a three button responder experiment using an Arduino UNO. The experiment uses four buttons, three LEDs, resistors, a breadboard, jumper wires, and a USB cable. Pressing each button will illuminate the corresponding LED until the reset button is pressed, at which point all LEDs will turn off.

Uploaded by

pr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Responder Experiment

Overview

This is a three responder experiment.

Specification
Button : Size: 6 x 6 x 5mm
Temperature: -30 ~ +70 Centigrade

Pin definition
za
Is the definition of Button pin:
ra
sm

1
Hardware required
Material diagram Material name Number

Button 4

LED 3

220/330Ω resistor 3

10KΩ resistor 4

USB Cable 1

UNO R3 1
za
Breadboard 1
ra
sm

Jumper wires Several

2
Connection

Schematic

za
ra
sm

3
Connection diagram

za
ra
sm

Note: Button using 10KΩ resistor, LED use 220/330Ω resistor.

4
Sample code
Note: sample code under the Sample code folder
int Redled=8; // set Red LED as “output”
int Yellowled=7; // set Yellow LED as “output”
int Greenled=6; // set Green LED as “output”
int Key1=5; // initialize pin for Red button
int Key2=4; // initialize pin for Yellow button
int Key3=3; // initialize pin for Green button
int KeyRest=2; // initialize pin for reset button
int Red;
int Yellow;
int Green;
void setup()
{
pinMode(Redled,OUTPUT);
pinMode(Yellowled,OUTPUT);
pinMode(Greenled,OUTPUT);
pinMode(Key1,INPUT);
pinMode(Key2,INPUT);
za
pinMode(Key3,INPUT);
pinMode(KeyRest,INPUT);
ra

}
void loop() // repeatedly read pins for buttons
{
sm

Red=digitalRead(Key1);
Yellow=digitalRead(Key2);
Green=digitalRead(Key3);
if(Red==HIGH)Red_YES();
if(Yellow==HIGH)Yellow_YES();
if(Green==HIGH)Green_YES();
}

void Red_YES() // execute the code until Red light is on; end cycle when reset button is
pressed
{
while(digitalRead(KeyRest)==0)
{
digitalWrite(Redled,HIGH);
digitalWrite(Greenled,LOW);
digitalWrite(Yellowled,LOW);
}
clear_led();
}

5
void Yellow_YES() // execute the code until Yellow light is on; end cycle when reset
button is pressed
{
while(digitalRead(KeyRest)==0)
{
digitalWrite(Redled,LOW);
digitalWrite(Greenled,LOW);
digitalWrite(Yellowled,HIGH);
}
clear_led();
}
void Green_YES() // execute the code until Green light is on; end cycle when reset
button is pressed
{
while(digitalRead(KeyRest)==0)
{
digitalWrite(Redled,LOW);
digitalWrite(Greenled,HIGH);
digitalWrite(Yellowled,LOW);
za
}
clear_led();
}
ra

void clear_led() // all LED off


{
sm

digitalWrite(Redled,LOW);
digitalWrite(Greenled,LOW);
digitalWrite(Yellowled,LOW);
}

6
Example picture

za
ra
sm

7
Language reference
Tips:click on the following name to jump to the web page.
If you fail to open, use the Adobe reader to open this document.
digitalRead()
== (equality)

Application effect
Whichever button is pressed first, then the corresponding LED will be on!

If you want to reset, hit the Reset button.

******************************************************************************************
* About Smraza:
* We are a leading manufacturer of electronic components for Arduino and Raspberry
Pi.
* Official website: http://www.smraza.com/
* We have a professional engineering team dedicated to providing tutorials and
za
support to help you get started.
* If you have any technical questions, please feel free to contact our support staff via
email at [email protected]
ra

* We truly hope you enjoy the product, for more great products please visit our
Amazon US store: http://www.amazon.com/shops/smraza
sm

Amazon CA store: https://www.amazon.ca/shops/AMIHZKLK542FQ


Amazon UK store: http://www.amazon.co.uk/shops/AVEAJYX3AHG8Q
Amazon DE store: http://www.amazon.de/shops/AVEAJYX3AHG8Q
Amazon FR store: http://www.amazon.fr/shops/AVEAJYX3AHG8Q
Amazon IT store: http://www.amazon.it/shops/AVEAJYX3AHG8Q
Amazon ES store: https://www.amazon.es/shops/AVEAJYX3AHG8Q
******************************************************************************************

You might also like