added example for controlling a traffic light
This commit is contained in:
parent
3a8fa2a56e
commit
f9ed357485
|
@ -4,11 +4,13 @@ extern void loop();
|
|||
|
||||
//#include "blink/blink.h"
|
||||
//#include "button_poll/button.h"
|
||||
#include "button_interupt/button.h"
|
||||
//#include "button_interupt/button.h"
|
||||
#include "trafficlight/trafficlight.h"
|
||||
|
||||
//#define BLINK
|
||||
//#define BUTTON_POLL
|
||||
#define BUTTON_INTERRUPT
|
||||
//#define BUTTON_INTERRUPT
|
||||
#define TRAFFIC_LIGHT
|
||||
|
||||
int main() {
|
||||
init();
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by servostar on 27.10.23.
|
||||
//
|
||||
|
||||
#include "trafficlight.h"
|
||||
|
||||
#ifdef TRAFFIC_LIGHT
|
||||
|
||||
void init() {
|
||||
// set Port B bit 0,1,2 to output mode
|
||||
DDRB = 0b00000111;
|
||||
|
||||
// set port B bit 2 (red) to one
|
||||
PORTB = 0b00000100;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
_delay_ms(200);
|
||||
// set red orange
|
||||
PORTB ^= 0b00000010;
|
||||
_delay_ms(200);
|
||||
|
||||
// set green
|
||||
PORTB ^= 0b00000111;
|
||||
_delay_ms(500);
|
||||
|
||||
// set orange
|
||||
PORTB ^= 0b00000011;
|
||||
_delay_ms(500);
|
||||
|
||||
// set to red
|
||||
PORTB ^= 0b00000110;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// Created by servostar on 27.10.23.
|
||||
//
|
||||
|
||||
#ifndef ARDUINO_TRAFFICLIGHT_H
|
||||
#define ARDUINO_TRAFFICLIGHT_H
|
||||
|
||||
#include "prelude.h"
|
||||
|
||||
void init();
|
||||
void loop();
|
||||
|
||||
#endif //ARDUINO_TRAFFICLIGHT_H
|
Loading…
Reference in New Issue