Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #include <VirtualWire.h>
- #define PIN 6
- #define NUMPIXELS 20
- Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
- void Mode(int NoOfMode){
- switch(NoOfMode){
- case 0: //Start
- for(int i = 0; i < NUMPIXELS; i++){
- pixels.setPixelColor(i, pixels.Color(255,255,255));
- pixels.show();
- }
- break;
- case 1: //Red Intens
- for(int i = 0; i < NUMPIXELS; i++){
- pixels.setPixelColor(i, pixels.Color(255,0,0));
- pixels.show();
- }
- break;
- case 2: //Green Intens
- for(int i = 0; i < NUMPIXELS; i++){
- pixels.setPixelColor(i, pixels.Color(0,0,255));
- pixels.show();
- }
- break;
- case 3: //Blue Intens
- for(int i = 0; i < NUMPIXELS; i++){
- pixels.setPixelColor(i, pixels.Color(0,255,0));
- pixels.show();
- }
- break;
- }
- }
- void setup()
- {
- Mode(0);
- vw_setup(2000);
- vw_set_rx_pin(4);
- vw_rx_start();
- }
- void loop()
- {
- uint8_t buf[VW_MAX_MESSAGE_LEN];
- uint8_t buflen = VW_MAX_MESSAGE_LEN;
- String message;
- int messageInt;
- message = "";
- messageInt = 0;
- vw_wait_rx();
- vw_get_message(buf, &buflen);
- for (int i = 0; i < buflen; i++){
- message +=char(buf[i]);
- }
- messageInt = message.toInt();
- Mode(messageInt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement