Last active
February 14, 2019 17:19
-
-
Save maxux/f874020928452cc3de5e9dee6f6b5921 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "w5100.h" | |
#define PIN_RED 3 | |
#define PIN_GREEN 5 | |
#define PIN_BLUE 6 | |
byte macaddr[] = {0xa2, 0x43, 0x42, 0x42, 0x42, 0x01}; | |
Wiznet5100 w5100; | |
uint8_t buffer[512] | |
void setup() { | |
// init ethernet | |
w5100.begin(macaddr); | |
pinMode(PIN_RED, OUTPUT); | |
pinMode(PIN_GREEN, OUTPUT); | |
pinMode(PIN_BLUE, OUTPUT); | |
// initial color | |
analogWrite(PIN_RED, 20); | |
analogWrite(PIN_GREEN, 0); | |
analogWrite(PIN_BLUE, 0); | |
} | |
void loop() { | |
if(w5100.readFrame(buffer, sizeof(buffer)) == 0) | |
return; | |
if(buffer[12] != 0x88 || buffer[13] != 0xB6) | |
return; | |
analogWrite(PIN_RED, buffer[14]); | |
analogWrite(PIN_GREEN, buffer[15]); | |
analogWrite(PIN_BLUE, buffer[16]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment