Advertisement
Guest User

Odbiornik

a guest
Aug 15th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #include <VirtualWire.h>
  3.  
  4. #define PIN 6
  5. #define NUMPIXELS 20
  6.  
  7. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  8.  
  9. void Mode(int NoOfMode){
  10. switch(NoOfMode){
  11. case 0: //Start
  12. for(int i = 0; i < NUMPIXELS; i++){
  13. pixels.setPixelColor(i, pixels.Color(255,255,255));
  14. pixels.show();
  15. }
  16. break;
  17. case 1: //Red Intens
  18. for(int i = 0; i < NUMPIXELS; i++){
  19. pixels.setPixelColor(i, pixels.Color(255,0,0));
  20. pixels.show();
  21. }
  22. break;
  23. case 2: //Green Intens
  24. for(int i = 0; i < NUMPIXELS; i++){
  25. pixels.setPixelColor(i, pixels.Color(0,0,255));
  26. pixels.show();
  27. }
  28. break;
  29. case 3: //Blue Intens
  30. for(int i = 0; i < NUMPIXELS; i++){
  31. pixels.setPixelColor(i, pixels.Color(0,255,0));
  32. pixels.show();
  33. }
  34. break;
  35. }
  36. }
  37.  
  38. void setup()
  39. {
  40. Mode(0);
  41. vw_setup(2000);
  42. vw_set_rx_pin(4);
  43. vw_rx_start();
  44. }
  45.  
  46. void loop()
  47. {
  48. uint8_t buf[VW_MAX_MESSAGE_LEN];
  49. uint8_t buflen = VW_MAX_MESSAGE_LEN;
  50. String message;
  51. int messageInt;
  52.  
  53. message = "";
  54. messageInt = 0;
  55. vw_wait_rx();
  56. vw_get_message(buf, &buflen);
  57.  
  58.  
  59. for (int i = 0; i < buflen; i++){
  60. message +=char(buf[i]);
  61. }
  62.  
  63. messageInt = message.toInt();
  64.  
  65. Mode(messageInt);
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement