Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2023:tmiu:trafficlightcontroller [2023/05/22 12:56]
fabius_sever.pop
pm:prj2023:tmiu:trafficlightcontroller [2023/05/29 17:53] (current)
fabius_sever.pop
Line 39: Line 39:
  
 <note tip> <note tip>
 +
 +// Trafic Light Controller with 7 segment display
 +// Pop Fabius Sever FILS 1221B
 +
 +#include "​SevSeg.h"​
 +
 +SevSeg S;
 +byte CommonPins[] = {};            ​
 +byte SegPins[] = {2,​3,​4,​5,​6,​7,​8}; ​
 +
 +int red = 9;
 +int yellow = 10;
 +int green=11;
 +
 +void setup()
 +{
 +  S.begin(COMMON_CATHODE,​ 1, CommonPins, SegPins, 1);
 +
 +  pinMode(9, OUTPUT);
 +  pinMode(10, OUTPUT);
 +  pinMode(11, OUTPUT);
 +
 +  digitalWrite(red,​ HIGH);
 +}
 +
 +void loop()
 +{
 +  for(int i=9; i>=0; i--)
 +  {
 +    disPlay(i);
 +    delay(2000);​
 +    if(i<=3)
 +    {
 +      digitalWrite(yellow,​ HIGH);
 +      digitalWrite(red,​ LOW);
 +    }    ​
 +  }
 +
 +  digitalWrite(green,​ HIGH);
 +  digitalWrite(yellow,​ LOW);
 +
 +  for(int i=9; i>=0; i--)
 +  {
 +    disPlay(i);
 +    delay(2000);​
 +    if(i<=3)
 +    {
 +      digitalWrite(yellow,​ HIGH);
 +      digitalWrite(green,​ LOW);
 +    }
 +    ​
 +  }
 +
 +  digitalWrite(red,​ HIGH);
 +  digitalWrite(yellow,​ LOW);
 +  digitalWrite(green,​ LOW);
 +  ​
 +    ​
 +
 +}
 +
 +
 +void disPlay(int num)
 +{
 +    S.setNumber(num);​
 +    S.refreshDisplay();​
 +    delay(20);
 +}
 +
 +
  
    The code was written in the Arduino IDE development environment and uses the SevSeg library to control the 7-segment display.    The code was written in the Arduino IDE development environment and uses the SevSeg library to control the 7-segment display.
pm/prj2023/tmiu/trafficlightcontroller.1684749391.txt.gz · Last modified: 2023/05/22 12:56 by fabius_sever.pop
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0