Hello
I want to build a controller with several Faders, Buttons, etc. etc.
Now I'm a little bit stuck with programming and i'm not that genius that i could solve it...
In my file i first read out the faders (analog 1-8), then map them up to a 16Bit Value (receiving device accepts only 16 Bit). And then arduino should send via the ethernet shield as following:
"CS 1 CR"
How can i do that? I'm sure i did something weird....
well, here's the monster
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>// MAC und IP Setup
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0F, 0x1E, 0x8D };
IPAddress ip(192, 168, 1, 210);// UDP Listen Port 48631 for Composer H/W, 48630 for SYM Designer H/W
unsigned int localPort = 48631;// Remote Client Setup
IPAddress destinationIP (192, 168, 1, 201);
unsigned int destinationPort = 48631;// Naming Inputs
const int Fader1 = A0;
const int Fader2 = A1;
const int Fader3 = A2;
const int Fader4 = A3;
const int Fader5 = A4;
const int Fader6 = A5;
const int Fader7 = A6;
const int Fader8 = A7;const int Button1 = 0;
const int Button2 = 1;
const int Button3 = 2;
const int Button4 = 3;
const int Button5 = 5;
const int Button6 = 6;
const int Button7 = 7;
const int Button8 = 8;const int LED1 = 9; //LED 2-8 May only be used with Ardunio Mega => on Uno Pins 10-13 and 4 will be needed for Ethernet Shield
const int LED2 = 11; //On Mega Pin 4, 10 and 50-52 will be needed for Ethernet Shield
const int LED3 = 12;
const int LED4 = 13;
const int LED5 = 14;
const int LED6 = 15;
const int LED7 = 16;
const int LED8 = 17;// Naming S Values
int FV1 = 0;
int FV2 = 0;
int FV3 = 0;
int FV4 = 0;
int FV5 = 0;
int FV6 = 0;
int FV7 = 0;
int FV8 = 0;int BV1 = 0;
int BV2 = 0;
int BV3 = 0;
int BV4 = 0;
int BV5 = 0;
int BV6 = 0;
int BV7 = 0;
int BV8 = 0;int LV1 = 0;
int LV2 = 0;
int LV3 = 0;
int LV4 = 0;
int LV5 = 0;
int LV6 = 0;
int LV7 = 0;
int LV8 = 0;// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
Serial.begin(9600);// Configuring digital I/O
pinMode (Button1, INPUT);
pinMode (Button2, INPUT);
pinMode (Button3, INPUT);
pinMode (Button4, INPUT);
pinMode (Button5, INPUT);
pinMode (Button6, INPUT);
pinMode (Button7, INPUT);
pinMode (Button8, INPUT);pinMode (LED1, OUTPUT);
pinMode (LED2, OUTPUT);
pinMode (LED3, OUTPUT);
pinMode (LED4, OUTPUT);
pinMode (LED5, OUTPUT);
pinMode (LED6, OUTPUT);
pinMode (LED7, OUTPUT);
pinMode (LED8, OUTPUT);}
void loop() {
// Read values
FV1 = analogRead (Fader1);
FV2 = analogRead (Fader2);
FV3 = analogRead (Fader3);
FV4 = analogRead (Fader4);
FV5 = analogRead (Fader5);
FV6 = analogRead (Fader6);
FV7 = analogRead (Fader7);
FV8 = analogRead (Fader8);// Upscale from 10 Bit to 16 Bit
FV1 = map (FV1, 0, 1023, 0, 65535);
FV2 = map (FV2, 0, 1023, 0, 65535);
FV3 = map (FV3, 0, 1023, 0, 65535);
FV4 = map (FV4, 0, 1023, 0, 65535);
FV5 = map (FV5, 0, 1023, 0, 65535);
FV6 = map (FV6, 0, 1023, 0, 65535);
FV7 = map (FV7, 0, 1023, 0, 65535);
FV8 = map (FV8, 0, 1023, 0, 65535);Serial.print(FV1);
Serial.print("\t");
// send Data to the IP address and port defined above
Udp.beginPacket(destinationIP, destinationPort);
Udp.write("CS <");
Udp.write(FV1);
Udp.write(">");
Udp.endPacket();delay(10);
}