Compare commits

..

No commits in common. "6eaf4518fa4d0daa17efad11b9320150be22e273" and "f9ed357485a8d1a9116509ec006297e3218a668a" have entirely different histories.

9 changed files with 17 additions and 134 deletions

View File

@ -12,13 +12,3 @@
platform = atmelavr
board = nanoatmega328
framework = arduino
build_src_filter =
+<*>
-<.git/>
-<.svn/>
-<blink/>
-<button_interupt/>
-<button_poll/>
-<trafficlight/>
-<summer/>
+<summer_controlled/>

View File

@ -4,6 +4,8 @@
#include "button.h"
#ifdef BUTTON_INTERRUPT
ISR(INT0_vect)
{
PORTB = 0;
@ -41,3 +43,5 @@ void init() {
void loop() {
}
#endif

View File

@ -10,6 +10,8 @@
// PORTx set bit of port value
// PINx read voltage of bit of port D
#ifdef BUTTON_POLL
void init() {
// ---------------------------------------
// set Port B to output
@ -41,3 +43,5 @@ void loop() {
CLR_BIT(PORTB, DDB5);
}
}
#endif

View File

@ -5,9 +5,12 @@ extern void loop();
//#include "blink/blink.h"
//#include "button_poll/button.h"
//#include "button_interupt/button.h"
//#include "trafficlight/trafficlight.h"
//#include "summer/summer.h"
#include "summer_controlled/summer.h"
#include "trafficlight/trafficlight.h"
//#define BLINK
//#define BUTTON_POLL
//#define BUTTON_INTERRUPT
#define TRAFFIC_LIGHT
int main() {
init();

View File

@ -1,30 +0,0 @@
//
// Created by servostar on 30.10.23.
//
#include "summer.h"
ISR (TIMER0_COMPA_vect)
{
PORTB = ~PORTB;
}
void init() {
DDRB = 255;
PORTB = 0;
TCCR0A |= (1 << WGM01); // set timer to CTC
OCR0A = 0x70; // count up to this value 440Hz
// OCR0A = 0x117; // count up to this value 265Hz
TIMSK0 |= (1 << OCIE0A); // enable timer 0
TCCR0B |= (1 << CS02) | (1 << CS00); // start timer and set prescaler to 1024
sei(); // enable interrupts
}
void loop() {
}

View File

@ -1,13 +0,0 @@
//
// Created by servostar on 30.10.23.
//
#ifndef ARDUINO_SUMMER_H
#define ARDUINO_SUMMER_H
#include "prelude.h"
void init();
void loop();
#endif //ARDUINO_SUMMER_H

View File

@ -1,65 +0,0 @@
//
// Created by servostar on 30.10.23.
//
#include "summer.h"
void setup_summer_it();
void setup_button_it();
ISR (TIMER0_COMPA_vect)
{
PORTB = ~PORTB;
}
ISR(INT0_vect)
{
OCR0A = 18; // count up to this value 440Hz
}
ISR(INT1_vect)
{
OCR0A = 30; // count up to this value 265Hz
}
void init() {
setup_summer_it();
setup_button_it();
sei(); // enable interrupts
}
void setup_button_it() {
// set Port D to input (bit 2/3, remember bit 0/1 are for UART)
SET_INPUT(DDRD, DDD2);
SET_INPUT(DDRD, DDD3);
// put 5V on input (make it pull up resistor)
SET_BIT(PORTD, DDD2);
SET_BIT(PORTD, DDD3);
// configure interrupt mode
SET_INTERRUPT_MODE(0, FALLING);
SET_INTERRUPT_MODE(1, FALLING);
// enable interrupt 0 and 1
ENABLE_INTERRUPT(0);
ENABLE_INTERRUPT(1);
}
void setup_summer_it() {
DDRB = 255;
PORTB = 0;
TCCR0A |= (1 << WGM01); // set timer to CTC
OCR0A = 0x70; // count up to this value 440Hz
// OCR0A = 0x117; // count up to this value 265Hz
TIMSK0 |= (1 << OCIE0A); // enable timer 0
TCCR0B |= (1 << CS02) | (1 << CS00); // start timer and set prescaler to 1024
}
void loop() {
}

View File

@ -1,13 +0,0 @@
//
// Created by servostar on 30.10.23.
//
#ifndef ARDUINO_SUMMER_H
#define ARDUINO_SUMMER_H
#include "prelude.h"
void init();
void loop();
#endif //ARDUINO_SUMMER_H

View File

@ -4,6 +4,8 @@
#include "trafficlight.h"
#ifdef TRAFFIC_LIGHT
void init() {
// set Port B bit 0,1,2 to output mode
DDRB = 0b00000111;
@ -29,3 +31,4 @@ void loop() {
// set to red
PORTB ^= 0b00000110;
}
#endif