// Traffic light w/ pedestrian button....
// (c)2013 IronCreek Software
#include <avr/io.h>
#include <avr/interrupt.h>
// (LED registers)
// NOTE: All LEDs must be hooked up on the same PORT
#define LED_PORT PORTB
#define LED_DDR DDRB
#define LED_MASK 0x1F
// LED pins
#define PED_GO 0x01
#define PED_STOP 0x02
#define GREEN 0x04
#define YELLOW 0x08
#define RED 0x10
// Pedestrian button PORT & PIN
#define BTN_PIN PIND
#define BTN_PORT PORTD
#define BTN_DDR DDRD
#define BTN 0x80
namespace
{
// Index into LED_STATES for code clarity below
#define STOP 3
#define CROSS 4
#define END_CYCLE 4
#define END_CROSS 7
// Delays are in 16.384ms units (1 = 16.384ms)
// First column has delays, second column has LED bits
const uint8_t LED_STATES[][2] = {
// Normal cycle
{ 25, PED_STOP | RED | YELLOW },
{ 200, PED_STOP | GREEN },
{ 50, PED_STOP | YELLOW },
{ 200, PED_STOP | RED, },
// Pedestrian cycle
{ 25, PED_STOP | RED },
{ 150, PED_GO | RED },
{ 25, PED_STOP | RED },
};
// Helper variables for timer
volatile uint8_t timer = 0;
volatile uint8_t change_state = 0;
ISR(TIMER0_OVF_vect)
{
if (change_state == 0 && --timer == 0)
change_state = 1;
}
void setLights(const uint8_t state)
{
LED_PORT = LED_STATES[state][1];
timer = LED_STATES[state][0];
}
}
__attribute__((OS_main)) int main()
{
uint8_t state = STOP;
uint8_t ped_request = 0;
// Setup ports
LED_DDR |= LED_MASK;
BTN_PORT |= BTN; // Enable pull-up
setLights(state);
// Start timer
TIMSK0 |= (1 << TOIE0);
TCCR0B |= (1 << CS02) | (1 << CS00);
sei();
// Main loop
for(;;)
{
if (change_state)
{
++state;
if (state == END_CYCLE || state == END_CROSS)
state = 0;
if (state == STOP && ped_request)
{
state = CROSS;
ped_request = 0;
}
setLights(state);
change_state = 0;
}
// Check pedestrian crossing button
if ((BTN_PIN & BTN) == 0 && state < CROSS)
ped_request = 1;
}
}
ARM assembly lang please write code Street Crossing - This consists of a street light (red,yellow,green...
write code in ARM assembly lang Ladder Game - This game involves a setup of LEDs in a row and a button. The goal is to get from the bottom led all the way to the top without them resetting. The LEDs will flash and you can only move up one led at a time, when the led is lit up, or else you get reset to the bottom.
Hi, Please can anyone help me to solve this question in ARM assembly language ASAP?? Thank you, Task 4 On the Cornish, there is a pedestrian traffic light with a push button. Under normal condition, the green light is on for the cars to go, and the pedestrian light is red. When a pedestrian wants to cross, he/she presses on the push button and the red light turns on for the cars and green for pedestrian. Design this traffic light...
Can someone please show me a circuit diagram so i can see how to construct this on a bread board i am id 6 yhanks in advance EEET-2251: Course & Projoct Guide 2018 EEET-2251: Cousc &Projoct Guide 2018 affic Light Controller A single switch must set your HC74 based state machine to the initial state (the U state This lab will get you to design a simple controller for a pedestrian crossing based on synchronous digital logic. You will master...