Difference between revisions of "Lesson 17--Microduino Button Control Digital Tube"
(→Program) |
|||
Line 14: | Line 14: | ||
**Breadboard one piece | **Breadboard one piece | ||
**Digital tube one | **Digital tube one | ||
− | ** | + | **Buttons two |
**220Ω (100Ω~1kΩ) one | **220Ω (100Ω~1kΩ) one | ||
**USB Data cable one | **USB Data cable one | ||
Line 89: | Line 89: | ||
==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:第十七课-Microduino独立按键让数码管加减连接图.jpg|600px|center|thumb]] | [[File:第十七课-Microduino独立按键让数码管加减连接图.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 | + | Step 4: Digital displays initial value 5, then press that two buttons respectively, what will happen!! |
==Result== | ==Result== |
Latest revision as of 08:19, 12 September 2016
Language: | English • 中文 |
---|
ObjectiveThis tutorial will teach you how to use the buttons to add and subtract the digital tube displayed value. There are two buttons, one is used to increase the value, another is used to decrease value. EquipmentMicroduino-Core Microduino-FT232R
SchematicPin Table
ProgramDownload program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced/MicroduinoDigitalSubtraction #include "SevSeg.h"
SevSeg sevseg;
int i=5;
void setup() {
//Define used pins
sevseg.Begin(1,2,3,4,5,6,7,8,9,10,11,12,13);
pinMode(2, INPUT); //D2 use to add
pinMode(3, INPUT); //D3 use to subtract
sevseg.PrintOutput();
sevseg.NewNum(i, 4);
}
void loop() {
//Enable the output function
sevseg.PrintOutput();
if(digitalRead(2)==HIGH) {//If press button 2
i++;
sevseg.NewNum(i, 4);
delay(200); //Delay 50ms
}
else if(digitalRead(3)==HIGH) {//If press button 3
i--;
sevseg.NewNum(i, 4);
delay(200); //Delay 50ms
}
} 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: Digital displays initial value 5, then press that two buttons respectively, what will happen!! ResultPress two buttons respectively, the value will increase one or decrease one. Video |