1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include <Ethernet.h>
- #include <EthernetUdp.h>
- #include <SPI.h>
- #include <OSCBundle.h>
- EthernetUDP Udp;
- IPAddress ip(128, 32, 122, 252);
- IPAddress outIp(128, 32, 122, 125);
- const unsigned int outPort = 9999;
- byte mac[] = {
- 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
- void setup() {
- Ethernet.begin(mac,ip);
- Udp.begin(8888);
- }
- void loop(){
-
- OSCBundle bndl;
-
- bndl.add("/analog/0").add((int32_t)analogRead(0));
- bndl.add("/analog/1").add((int32_t)analogRead(1));
- bndl.add("/digital/5").add((digitalRead(5)==HIGH)?"HIGH":"LOW");
- Udp.beginPacket(outIp, outPort);
- bndl.send(Udp);
- Udp.endPacket();
- bndl.empty();
- bndl.add("/mouse/step").add((int32_t)analogRead(0)).add((int32_t)analogRead(1));
- bndl.add("/units").add("pixels");
- Udp.beginPacket(outIp, outPort);
- bndl.send(Udp);
- Udp.endPacket();
- bndl.empty();
- delay(1000);
- }
|