I am wondering if you can help me with this code in terms of ethernet connection and Arduino UNO ?
Im trying to send UDP data from Max/MSP to Arduino Uno, - I know I have to define IP address and Port , (thats fine I get that part)
But I think I am missing code for ethernet in the (Void Loop Section)
Can you please have a look over to me to see I am getting it
Thanks Darren
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#define PIN 11
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// the dns server ip
//IPAddress dnServer(192, 168, 206, 31);
// the router's gateway address:
//IPAddress gateway(192, 168, 0, 1);
// the subnet:
//the IP address is dependent on your network
IPAddress ip(192, 254, 206, 31);
EthernetUDP Udp;
unsigned int localPort = 7777; // local port to listen on
// An EthernetUDP instance to let us send and receive packets over UDP
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);
int pixel = 4; // pixel number that you're changing
int red = 0; // red value
int green = 255; // green value
int blue = 12; // blue value
void setup() {
// start the Ethernet and UDP:
Serial.begin(9600);
Serial.setTimeout(10); // set serial timeout
strip.begin(); // initialize pixel strip
strip.show(); // Initialize all pixels to 'off'
Ethernet.begin(mac, ip);
Udp.begin(localPort);
//print out the IP address
Serial.print("IP = ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for serial:
IPAddress remote = Udp.remoteIP();
if (Serial.available() > 0) {
if (Serial.read() == 'C') { // string should start with C
pixel = Serial.parseInt(); // then an ASCII number for pixel number
red = Serial.parseInt(); // then an ASCII number for red
green = Serial.parseInt(); // then an ASCII number for green
blue = Serial.parseInt(); // then an ASCII number for blue
}
}
strip.setPixelColor(pixel, red, green, blue);// set the color for this pixel
strip.show(); // refresh the strip
}