• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Arduino Traffic Light With LED Display Timer With Push Button Switch

By Abhishek Ghosh March 26, 2017 10:55 am Updated on April 9, 2017

Arduino Traffic Light With LED Display Timer With Push Button Switch

Advertisement

We have some tutorials around TM1637 7 segment LED display. Here is Code and Circuit Diagram To Create Arduino Traffic Light With LED Display Timer With Push Button Switch. This logical system used for many things including water dispenser, washing machine, air conditioner. Here is a very low quality video for demonstration purpose :

 

Components Needed For This Arduino Traffic Light With LED Display Timer With Push Button Switch

 

It is better if you have basic electronic components kit. However, here is a list for developmental version for testing on breadboard :

  1. Breadboard
  2. Jumper wires (male)
  3. 1K Ohm resistor
  4. Arduino UNO or cheap Arduino components
  5. 3 LEDs – green, red and yellow
  6. Push button switch
  7. TM1637 seven segment LED display

 

 

Circuit Diagram and Code For This Arduino Traffic Light

 

Here is a kind of infographics showing the circuit diagram for any level of user with other information.

Advertisement

---

Arduino-Traffic-Light-With-LED-Display-Timer-With-Push-Button-Switch

The project is on Fritzing. Code is separately kept on Github too.

In the code you’ll see the line :

Vim
1
const unsigned long sprintDuration = 70000; // change time

You can increase the value from 70000 to increase the timer duration.

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
const int buttonPin = 1;
const int clock = 2;
const int data = 3;
const uint8_t red = 12;
const uint8_t green = 13;
const uint8_t yellow = 11;
uint8_t digits[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f };
void setup()
{
  pinMode(buttonPin, INPUT);
  pinMode(clock, OUTPUT);
  pinMode(data, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(yellow, OUTPUT);
  setupInterrupt();
  start();
  writeValue(0x8f);
  stop();
  write(0x00, 0x00, 0x00, 0x00);
}
 
byte tcnt2;
unsigned long time = 0;
void setupInterrupt()
{
  TIMSK2 &= ~(1<<TOIE2);    
  TCCR2A &= ~((1<<WGM21) | (1<<WGM20));  
  TCCR2B &= ~(1<<WGM22);    
  ASSR &= ~(1<<AS2);  
  TIMSK2 &= ~(1<<OCIE2A);    
  TCCR2B |= (1<<CS22)  | (1<<CS20);
  TCCR2B &= ~(1<<CS21);
  tcnt2 = 131;    
  TCNT2 = tcnt2;  
  TIMSK2 |= (1<<TOIE2);  
}
ISR(TIMER2_OVF_vect) {  
  TCNT2 = tcnt2;
  if(time > 0)
  {
    time--;
  }
}  
 
void loop()
{
  handleButton();
  displayTime();
}
void handleButton()
{
  const unsigned long sprintDuration = 50000; // change time
  static uint8_t previousButtonState = LOW;
 
  uint8_t buttonState = digitalRead(buttonPin);
  if(buttonState == LOW && previousButtonState == HIGH)
  {
    time = sprintDuration;
    digitalWrite(yellow, HIGH);
    digitalWrite(green, LOW);
    delay(500);
  }
 
  previousButtonState = buttonState;
}
void displayTime()
{
  unsigned long t = (unsigned long)(time/1000);  
  uint8_t minutes = (byte)((t / 60) % 60);
  uint8_t seconds = (byte)(t % 60);
  if(t > 0)
  {
    digitalWrite(red, HIGH);
    digitalWrite(green, LOW);
    digitalWrite(yellow, LOW);
  }
  else
  {
    digitalWrite(red, LOW);
    digitalWrite(green, HIGH);
    digitalWrite(yellow, LOW);
  }
   write(digits[minutes / 10], digits[minutes % 10] | ((seconds & 0x01) << 7) , digits[seconds / 10], digits[seconds % 10]);
}
void write(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth)
{
  start();
  writeValue(0x40);
  stop();  
  start();
  writeValue(0xc0);
  writeValue(first);
  writeValue(second);
  writeValue(third);
  writeValue(fourth);
 
  stop();
}
void start(void)
{
  digitalWrite(clock,HIGH);
  digitalWrite(data,HIGH);
  delayMicroseconds(5);
  
  digitalWrite(data,LOW);
  digitalWrite(clock,LOW);
  delayMicroseconds(5);
}
void stop(void)
{
  digitalWrite(clock,LOW);
  digitalWrite(data,LOW);
  delayMicroseconds(5);
  
  digitalWrite(clock,HIGH);
  digitalWrite(data,HIGH);
  delayMicroseconds(5);
}
bool writeValue(uint8_t value)
{
  for(uint8_t i = 0; i < 8; i++)
  {
    digitalWrite(clock, LOW);
    delayMicroseconds(5);  
    digitalWrite(data, (value & (1 << i)) >> i);
    delayMicroseconds(5);
    digitalWrite(clock, HIGH);
    delayMicroseconds(5);
  }
  digitalWrite(clock,LOW);
  delayMicroseconds(5);  
  pinMode(data,INPUT);
  digitalWrite(clock,HIGH);    
  delayMicroseconds(5);  
  bool ack = digitalRead(data) == 0;
  pinMode(data,OUTPUT);
  return ack;
}

Tagged With Arduino trafic light with counter curcit diagram , https://thecustomizewindows com/2017/03/arduino-traffic-light-led-display-timer-push-button-switch/ , arduino traffic light with button code , traffic lights with seven-segment countdown timer , traffic lights with 7 segment countdown timer with python code , paperuri:(0a1a9ea8a0b3ed5269108f2c948b6d1c) , what is the purpose of switch in traffic light? , arduino countdown with stop , arduino countdown timer with stop and reset , android stop light app
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Arduino Traffic Light With LED Display Timer With Push Button Switch

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How to Control Multiple Relays With Single Arduino ESP32?

    Before How to Control Multiple Relays With Single Arduino ESP32 Testing, You Need to Learn How to Create Multiple MQTT Channels & Fetch Data.

  • Arduino : LED Switch On By Push Button Switch Off By IR Obstacle Sensor

    Here is Circuit Diagram and Code To Make LED Switch On By Push Button Switch Off By IR Obstacle Sensor and Arduino Board.

  • Cheapest Arduino LED Clock With Arduino Clone at $8

    Here is Cheapest Arduino LED Clock Which With Arduino Clone Will Cost $8 To You. It Is Really Usable LED Clock For Any Purpose, Not For Fun.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Affordable Earphone/IEM for Audiophiles: HiFiMan RE-400 WaterlineOctober 2, 2023
  • What is Hardware Security Module (HSM)September 30, 2023
  • Transducer Technologies of HeadphonesSeptember 28, 2023
  • What is Analog-to-Digital Converter (ADC)September 27, 2023
  • Comparison of Tube Amplifiers and SemiconductorsSeptember 26, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy