Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <button.h>
- #include <console.h>
- #include <timer.h>
- #include <led.h>
- void send() {
- led_on(1);
- delay_ms(5000);
- led_on(0);
- printf("!\n");
- //fflush();
- delay_ms(1000);
- led_off(0);
- led_off(1);
- }
- static void button_callback(int btn_num, int val,
- __attribute__ ((unused)) int arg2,
- __attribute__ ((unsued)) void *ud) {
- if(val == 1) {
- send();
- }
- }
- int main(void) {
- button_subscribe(button_callback, NULL);
- int count = button_count();
- for(int i = 0; i<count; i++) {
- button_enable_interrupt(i);
- }
- while(1) {
- int c = getch();
- if(c == TOCK_FAIL) {
- printf("\n getch() failed\n");
- }
- else if(c == 33) {
- send();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement