Hi Wildbill,
I want to store the values i get from the video switcher as 2 intergers called "Preview" and "Program"
With this 2 integers i will control the output LED's
Below you can find my code I already have.
I problem is how to get and store the 2 values for Preview and Program
Kind regards
//Tally control based on Arduino uno, arduino Mux Shield and Arduino Ethernet Shield connected to Extron ISS408
//http://mayhewlabs.com/arduino-mux-shield (Analog inputs 0-2 are shifted to 3-5 (0-1 used by Ethernet shield))
//http://www.arduino.cc/en/Main/ArduinoEthernetShield
/*
This program is used to control a tally light for 8 camera's,
we use pin numbers 17-19 (instead of analog numbers 3-5).
Mux 0 is used to control camera tally 1-8
Mux 1 is used to control screen tally in parallel with Mux0
Tally RED (program) is controlled with even outputs 1, 3, 5, 7, 9, 11, 13, 15
Tally GREEN (preview) is controlled with od outputs 0, 2, 4, 6, 8, 10, 12, 14
Pin 8 is used to control the online LED
To simplify this code further, one might use nested for loops or function calls.
*/
//Give convenient names to the control pins
#define CONTROL0 5 //MUX control pin 0 (S3 is connected to Arduino pin 2)
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2
#define ConnectedLED 8
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0x5A, 0x61 };
byte ip[] = {
192,168,1,200};//192,168,254,252 };
// Enter the IP address of the server you're connecting to:
byte server[] = {
192,168,1,3};//192,168,254,254 };
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 23 is default for telnet;
// if you're using Processing's ChatServer, use port 10002):
Client client(server, 23);
void setup()
{
//Set MUX control pins to output
pinMode(CONTROL0, OUTPUT);
pinMode(CONTROL1, OUTPUT);
pinMode(CONTROL2, OUTPUT);
pinMode(CONTROL3, OUTPUT);
//Set ConnecedLED pin to output
pinMode (ConnectedLED, OUTPUT);
// start the Ethernet connection:
Ethernet.begin(mac, ip);
int Program = 0; // #input connected to Program
int Preview = 0; // #input connected to Preview
}
void readProgram()
{
Serial.println("Reading Program");
if (client.connected()){
client.println("1&");
delay(10);
}
}
void readPreview()
{
Serial.println("Reading Preview");
if (client.connected()){
client.println("1&");
delay(10);
}
}
void telnetconnect()
{
// start the serial library:
Serial.begin(9600);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("reconnecting...");
// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
digitalWrite (ConnectedLED, HIGH);
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
if (!client.connected())
{
Serial.println("not connected");
telnetconnect();
}
//Since all 3 multiplexers have the same control pins, the one multiplexer data line we want to
//talk to should be set to output and the other two multiplexer lines should be be 'bypassed' by
//setting the pins to input
//Turn on output to digital pin 17 and 18(MUX 0 and MUX 1) and turn off the other multiplexer data pins
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, INPUT);
////This for loop is used to scroll through the FIRST multiplexer
//for (int i=0; i<4; i++)
//{
// //The following 4 commands set the correct logic for the control pins to select the desired input
// //See the Arduino Bitwise AND Reference: http://www.arduino.cc/en/Reference/BitwiseAnd
// //See the Aruino Bitshift Reference: http://www.arduino.cc/en/Reference/Bitshift
// digitalWrite(CONTROL0, (i&15)>>3); //S3
// digitalWrite(CONTROL1, (i&7)>>2); //S2
// digitalWrite(CONTROL2, (i&3)>>1); //S1
// digitalWrite(CONTROL3, (i&1)); //S0
// digitalWrite(17, HIGH);
// digitalWrite(18, HIGH);
// delay(1000);
// digitalWrite(17, LOW);
// digitalWrite(18, LOW);
// delay(1000);
//}
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// as long as there are bytes in the serial queue,
// read them and send them out the socket if it's open:
while (Serial.available() > 0) {
char inChar = Serial.read();
if (client.connected()) {
client.print(inChar);
}
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
digitalWrite (ConnectedLED, LOW);
// do nothing:
//while(true);
}
//readProgram();
}