Arduino倒数计时器倒数计时器-项目开发项目开发
Components and supplies
Breadboard (generic)
× 1
Jumper wires (generic)
× 1
SparkFun 7-Segment Serial Display - Red
No breakout board board used in this project
× 1
USB-A to Mini-USB Cable
× 1
Arduino Mega 2560
× 1
Apps and online services
Arduino IDE
About this project
This project was a project designed specifically because I did not have a timer on hand. To use this project you simply just upload the code to your arduino (any type will work)
you will just need upload the code to the arduino and the countdown will automatically start. Should you want to change the total time you will need to change this part of code.
REMEMBER!!! 1000= 1 sec. so 60000 = sec 60 or the equation (SECx1000) will give you your total number to insert into the place of the 60000. Finally when you press the
reset button the counter automatically restarts.
long n = 60000; //start time -> CAN CHANGE TO WHATEVER TIME YOU WANT
Code
The code
The codeArduino
Use this code to run your countdown timer
//7 segement pin number - 7 segement light - arduino pin number
//pin 11 - A = 12
//pin 7 - B = 10
//pin 4 - C = 8
//pin 2 - D = 7
//pin 1 - E = 6
//pin 10 - F = 11
//pin 5 - G = 9
//pin 3 is decimal
/*
12 11 10 9 8 7
| | | | | |
A
---
F | | B
| G |
---
E | | C
| |
--- . dec
D
| | | | | |
1 2 3 4 5 6
*/
//pin 12 - first digit = 1
//pin 9 - second digit = 2
//pin 8 - third digit = 3
//pin 6 fourth digit = 4
const int a = 12;
const int b = 10;
const int c = 8;
const int d = 7;
const int e = 6;
const int f = 11;
评论0