PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
901B

  1. #include <OSCMessage.h>
  2. /*
  3. Make an OSC message and send it over UDP
  4. Adrian Freed
  5. */
  6. #include <Ethernet.h>
  7. #include <EthernetUdp.h>
  8. #include <SPI.h>
  9. #include <OSCMessage.h>
  10. EthernetUDP Udp;
  11. //the Arduino's IP
  12. IPAddress ip(128, 32, 122, 252);
  13. //destination IP
  14. IPAddress outIp(128, 32, 122, 125);
  15. const unsigned int outPort = 9999;
  16. byte mac[] = {
  17. 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields
  18. void setup() {
  19. Ethernet.begin(mac,ip);
  20. Udp.begin(8888);
  21. }
  22. void loop(){
  23. //the message wants an OSC address as first argument
  24. OSCMessage msg("/analog/0");
  25. msg.add((int32_t)analogRead(0));
  26. Udp.beginPacket(outIp, outPort);
  27. msg.send(Udp); // send the bytes to the SLIP stream
  28. Udp.endPacket(); // mark the end of the OSC Packet
  29. msg.empty(); // free space occupied by message
  30. delay(20);
  31. }