Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. /*
  2. * Byggern.c
  3. *
  4. * Created: 29.08.2019 15.20.29
  5. * Author : hanso
  6. */
  7.  
  8. #include <avr/io.h>
  9. #include <stdint.h>
  10. #include <stdio.h>
  11. #include "header/initialize.h"
  12. #include <util/delay.h>
  13.  
  14.  
  15. int main(void)
  16. {
  17.  
  18. system_initialize();
  19.  
  20.  
  21. while (1)
  22. {
  23.  
  24.  
  25. uint8_t left_slider = adc_read(LEFT_SLIDER_CHANNEL);
  26. uint8_t left_slider_percentage = percentage_from_8bit(left_slider);
  27. uint8_t left_button = (PINB & (1 << LEFT_BUTTON_PIN));
  28.  
  29. uint8_t right_slider = adc_read(RIGHT_SLIDER_CHANNEL);
  30. uint8_t right_slider_percentage = percentage_from_8bit(right_slider);
  31. uint8_t right_button = (PINB & (1 << RIGHT_BUTTON_PIN));
  32.  
  33. uint8_t joycon_vertical = adc_read(JOYCON_VERTICAL_CHANNEL);
  34. uint8_t joycon_vertical_percentage = percentage_from_8bit(joycon_vertical);
  35. char joycon_vertical_direction = joystick_direction(joycon_vertical,'y');
  36.  
  37. uint8_t joycon_horizontal = adc_read(JOYCON_HORIZONTAL_CHANNEL);
  38. uint8_t joycon_horizontal_percentage = percentage_from_8bit(joycon_horizontal);
  39. char joycon_horizontal_direction = joystick_direction(joycon_horizontal,'x');
  40.  
  41.  
  42. printf("Left Slider: %d \t Right Slider: %d \t Joycon Vertical: %c \t Joycon Horizontal: %c\n\r", left_button, right_button, joycon_vertical_direction,joycon_horizontal_direction);
  43.  
  44. _delay_ms(500);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement