Hi,
I'm trying to create a byte that contains all the program and tally information but there is someting wrong with the creation of the byte (and maybe also with me progamming skills ![]()
The byte is named payload.tally
This byte will later be send with a JeeLAb radio to wireless tally's
/*****************
* Example: ATEM Monitor
* Connects to the Atem Switcher and outputs changes to Preview and Program on the Serial monitor (at 9600 baud)
*
* - kasper
*/
/*****************
* TO MAKE THIS EXAMPLE WORK:
* - You must have an Arduino with Ethernet Shield (or compatible such as "Arduino Ethernet", http://arduino.cc/en/Main/ArduinoBoardEthernet)
* - You must have an Atem Switcher connected to the same network as the Arduino - and you should have it working with the desktop software
* - You must make specific set ups in the below lines where the comment "// SETUP" is found!
*/
// Including libraries:
#include <SPI.h>Â Â Â Â // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <ATEMTally.h>
#include <TextFinder.h>
#include <EEPROM.h>
//#include <MemoryFree.h>
// MAC address and IP address for this *particular* Arduino / Ethernet Shield!
// The MAC address is printed on a label on the shield or on the back of your device
// The IP address should be an available address you choose on your subnet where the switcher is also present
byte mac[] = {
 0x90, 0xA2, 0xDA, 0x0D, 0x6B, 0xB9 };   // <= SETUP! MAC address of the Arduino
IPAddress ip(192, 168, 10, 99);       // <= SETUP! IP address of the Arduino
// Include ATEM library and make an instance:
// Connect to an ATEM switcher on this address and using this local port:
// The port number is chosen randomly among high numbers.
#include <ATEM.h>
ATEM AtemSwitcher(IPAddress(192, 168, 10, 240), 56417);Â // <= SETUP (the IP address of the ATEM switcher)
// No-cost stream operator as described at
// http://arduiniana.org/libraries/streaming/
template<class T>
inline Print &operator <<(Print &obj, T arg)
{Â
 obj.print(arg);
 return obj;
}
// create a new AtemSwitcher and ATEMTally object
//ATEM AtemSwitcher;
ATEMTally ATEMTally;
Â
// define a structure for sending over the radio
struct {
 byte tally;
} payload;
void setup() {
 // Start the Ethernet, Serial (debugging) and UDP:
 Ethernet.begin(mac,ip);
 Serial.begin(9600);
 Serial << F("\n- - - - - - - -\nSerial Started\n");Â
 // Initialize a connection to the switcher:
//koen AtemSwitcher.serialOutput(true); // Remove or comment out this line for production code. Serial output may decrease performance!
 AtemSwitcher.connect();
 // Shows free memory:Â
//Â Serial << F("freeMemory()=") << freeMemory() << "\n";
}
void loop() {
 // Check for packets, respond to them etc. Keeping the connection alive!
 // VERY important that this function is called all the time - otherwise connection might be lost because packets from the switcher is
 // overlooked and not responded to.
  AtemSwitcher.runLoop();
 // If connection is gone anyway, try to reconnect:
 if (AtemSwitcher.isConnectionTimedOut()) {
  Serial << F("Connection to ATEM Switcher has timed out - reconnecting!\n");
  AtemSwitcher.connect();
 } else {
      payload.tally =
      for (uint8_t i=1;i<=8;i++) {
       bitset(AtemSwitcher.getProgramTally(i),8+i-1)
      }
      ;
       for (uint8_t i=1;i<=8;i++) {
       bitset(AtemSwitcher.getPreviewTally(i),i-1)
      }
      ;
      Serial.print ("Tally byte= ");
      Serial.println (payload.tally,BIN);
     Â
   Â
     Â
 }
 // If you fancy to make delays in your sketches, ALWAYS do it using the AtemSwitcher delay function - this will wait while calling ru
 // Loop() checking for packets and thus keeping the connection up.
  AtemSwitcher.delay(50);
 // If you monitor the serial output, you should see a lot of "ACK, rpID: xxxx" and then every 5 seconds this message:
//koen Serial << F("End of normal loop() - still kicking?\n");
 // Now, try also to disconnect the network cable - and see if it reconnects properly.
}
I hope someone can help me out.
Kind regards Koen