Difference between revisions of "Lesson 18--Microduino 4-way Responder"
(Created page with "{{Languate | 第十八课--Microduino 4路抢答器}} {| style="width: 800px;" |- | ==Objective== This tutorial will teach you to do a four-way responder using 5 buttons base...") |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{Language | 第十八课--Microduino 4路抢答器}} |
{| style="width: 800px;" | {| style="width: 800px;" | ||
|- | |- | ||
Line 26: | Line 26: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | ! Microduino Pin !! | + | ! Microduino Pin !! Digital Pin |
|- | |- | ||
| D10 || 1 | | D10 || 1 | ||
Line 50: | Line 50: | ||
==Program== | ==Program== | ||
+ | Download program: | ||
+ | https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced/Microduino4Responder | ||
+ | |||
<source lang="cpp"> | <source lang="cpp"> | ||
Line 87: | Line 90: | ||
==Debug== | ==Debug== | ||
− | + | Firstly download the library, unzip it and put to libraries folder of Arduino IDE, then restart Arduino IDE to load library. | |
− | Library | + | Library link: https://docs.google.com/file/d/0Bwrp4uluZCpNN1Q4dmFZX1MzWVE/edit |
This library can drive 4bits digital tube and support number, decimal point and easy to use. | This library can drive 4bits digital tube and support number, decimal point and easy to use. | ||
− | Step | + | Step 1: Copy the code to IDE and compile it |
− | Step | + | Step 2: Set up circuit, as follows: |
[[File:第十八课-Microduino4路抢答器连接图.jpg|600px|center|thumb]] | [[File:第十八课-Microduino4路抢答器连接图.jpg|600px|center|thumb]] | ||
There are two buttons and use the same connection. One end connects to power and on the other end, a signal line and GND in parallel. | There are two buttons and use the same connection. One end connects to power and on the other end, a signal line and GND in parallel. | ||
− | Step | + | Step 3: Run program |
− | Step 4: At beginning, the digital will display 0, press four buttons at the same time, the digital will display the button number of the | + | Step 4: At beginning, the digital will display 0, press four buttons at the same time, the digital will display the button number of the first pressed. |
==Result== | ==Result== |
Latest revision as of 08:20, 12 September 2016
Language: | English • 中文 |
---|
ObjectiveThis tutorial will teach you to do a four-way responder using 5 buttons based on Microduino. Four buttons are marked with the number 1 ~ 4 respectively, press the four buttons at the same time, digital tube will display the button number of the first press. The fifth button uses to reset. Equipment
Schematic
ProgramDownload program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced/Microduino4Responder #include "SevSeg.h"
SevSeg sevseg;
void setup() {
//Define used pins
sevseg.Begin(1,2,3,4,5,6,7,8,9,10,11,12,13);
pinMode(1, INPUT); //Pin 1 for button 1
pinMode(2, INPUT); //Pin 2 for button 2
pinMode(3, INPUT); //Pin 3 for button 3
pinMode(4, INPUT); //Pin 4 for button 4
sevseg.PrintOutput();
sevseg.NewNum(0, 4); // initial value is 0
}
void loop() {
//Enable output function
sevseg.PrintOutput();
//Reads the four button pin in cycle
for(int i=1; i<=4; i++) {
if(digitalRead(i)==HIGH) {//Press a button
while(1) {//Display the button number
sevseg.PrintOutput();
sevseg.NewNum(i, 4);
}
}
}
} DebugFirstly download the library, unzip it and put to libraries folder of Arduino IDE, then restart Arduino IDE to load library. Library link: https://docs.google.com/file/d/0Bwrp4uluZCpNN1Q4dmFZX1MzWVE/edit This library can drive 4bits digital tube and support number, decimal point and easy to use. Step 1: Copy the code to IDE and compile it Step 2: Set up circuit, as follows: There are two buttons and use the same connection. One end connects to power and on the other end, a signal line and GND in parallel. Step 3: Run program Step 4: At beginning, the digital will display 0, press four buttons at the same time, the digital will display the button number of the first pressed. ResultDigital will display the button number of the first pressed. The most right side is the reset button. Video |