Add examples and tasks
This commit is contained in:
parent
abeced81a2
commit
0339089da2
19
firmware/apps/example_1.c
Normal file
19
firmware/apps/example_1.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <avr/io.h>
|
||||
#include <pentabug/app.h>
|
||||
|
||||
// was bedeuten die einzelnen Worte?
|
||||
// was passiert?
|
||||
// geht das einfacher?
|
||||
|
||||
static void example(void) {
|
||||
if(!(PINB & 1)) {
|
||||
PORTD &= ~(1 << 4);
|
||||
}
|
||||
|
||||
|
||||
if(!(PINB & 2)) {
|
||||
PORTC &= ~(1 << 2);
|
||||
}
|
||||
}
|
||||
|
||||
REG(example);
|
18
firmware/apps/example_2.c
Normal file
18
firmware/apps/example_2.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <pentabug/hal.h>
|
||||
#include <pentabug/app.h>
|
||||
|
||||
// was erwartest du das passiert?
|
||||
// wie kann man das Problem lösen?
|
||||
|
||||
static void example(void) {
|
||||
if(button_state(LEFT)) {
|
||||
led_inv(LEFT);
|
||||
}
|
||||
|
||||
|
||||
if(button_state(RIGHT)) {
|
||||
motor_inv();
|
||||
}
|
||||
}
|
||||
|
||||
REG(example);
|
24
firmware/apps/example_3.c
Normal file
24
firmware/apps/example_3.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <pentabug/hal.h>
|
||||
#include <pentabug/app.h>
|
||||
#include <pentabug/music.h>
|
||||
|
||||
static void example(void) {
|
||||
if(button_clicked(LEFT)) {
|
||||
set_note(NOTE_C, 4);
|
||||
wait_ms(500);
|
||||
set_note(NOTE_D, 4);
|
||||
wait_ms(500);
|
||||
stop_note();
|
||||
}
|
||||
|
||||
|
||||
if(button_clicked(RIGHT)) {
|
||||
set_note(NOTE_D, 4);
|
||||
wait_ms(500);
|
||||
set_note(NOTE_C, 4);
|
||||
wait_ms(500);
|
||||
stop_note();
|
||||
}
|
||||
}
|
||||
|
||||
REG(example);
|
39
firmware/apps/example_4.c
Normal file
39
firmware/apps/example_4.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <pentabug/hal.h>
|
||||
#include <pentabug/app.h>
|
||||
|
||||
// was passiert?
|
||||
// gibt es probleme?
|
||||
// wie kann man das problem lösen?
|
||||
|
||||
static void init(void) {
|
||||
led_on(RIGHT);
|
||||
led_on(LEFT);
|
||||
}
|
||||
|
||||
static void example(void) {
|
||||
led_inv(LEFT);
|
||||
led_inv(RIGHT);
|
||||
|
||||
wait_ms(500);
|
||||
|
||||
led_inv(LEFT);
|
||||
|
||||
wait_ms(500);
|
||||
|
||||
led_inv(RIGHT);
|
||||
|
||||
wait_ms(500);
|
||||
|
||||
if(button_clicked(LEFT)) {
|
||||
motor_inv();
|
||||
wait_ms(500);
|
||||
motor_inv();
|
||||
wait_ms(500);
|
||||
motor_inv();
|
||||
wait_ms(500);
|
||||
motor_inv();
|
||||
wait_ms(500);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER(example, init, NULL);
|
Loading…
Reference in New Issue
Block a user