Advertisement
Guest User

RoverRemoteEasy

a guest
Oct 20th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. /*Car remote sketch by Bigboy™
  2.  Ten kod uzywa biblioteki HID od NicoHood
  3.   Zobacz dokumentacje Projektu HID aby dowiedziec sie wiecej.
  4.   https://github.com/NicoHood/HID/wiki/Consumer-API
  5.  idealne wartosci przyciskow 0 = nic 255 = mode 392 = prev 551 = next 749 = vol+ 1023 = vol-
  6.  rezystancje : pullup 1K, 3180R(1680+1500), 1680R(860+820), 860R(390+470), 390R, 0R
  7.   Wszystkie funkcje https://github.com/NicoHood/HID/blob/master/src/HID-APIs/ConsumerAPI.h
  8.  
  9. */
  10.  
  11. #include "HID-Project.h"
  12.  
  13. void setup() {
  14.   Consumer.begin();
  15. }
  16.  
  17. void loop() {
  18.     delay(100); //szybkosc dzialania przyciskow
  19.     int x;
  20.     x = analogRead(A0); //A0 to pin odczytu wartosci
  21.     if (x > 1000) { //wartosc 1023
  22.     Consumer.write(MEDIA_VOL_DOWN); //przycisk vol-
  23.     }
  24.     else if ( (x >= 700)  &&  (x <=800)    )   { //wartosc 749
  25.     Consumer.write(MEDIA_VOL_UP); //przycisk vol+
  26.     }
  27.     else if ( (x >= 500)  &&  (x <=600)    )   { //wartosc 551
  28.     Consumer.write(MEDIA_NEXT); //przycisk next
  29.     }
  30.     else if ( (x >= 350)  &&  (x <=450)    )   { //wartosc 392
  31.     Consumer.write(MEDIA_PREV); //przycisk prev
  32.     }
  33.     else if ( (x >= 200)  &&  (x <=300)    )   { //wartosc 255
  34.     Consumer.write(MEDIA_PLAY_PAUSE); //przycisk mode
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement