Skip to content

Commit

Permalink
Cleaned up project folder, updated Arduino sketch for new UDP API.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbarch committed Sep 30, 2012
1 parent 9e5e6c0 commit 78ee50c
Show file tree
Hide file tree
Showing 30 changed files with 10 additions and 3 deletions.
Expand Up @@ -4,7 +4,7 @@
************************************/
#include <SPI.h>
#include <Ethernet.h>
#include <Udp.h>
#include <EthernetUdp.h>
#include <Servo.h>

//Set the MAC address, static IP, gateway, and subnet of the network
Expand All @@ -13,13 +13,18 @@ byte ip[] = { 192, 168, 1, 22 };

//UDP Stuff
const int PORT = 4444; //Port of incoming UDP data

const int PACKET_SIZE = 8; //Size of the joystick data packet
byte joystick_data[PACKET_SIZE]; //Byte array for incoming data - [0] = leftY, [1] = leftX, [2] = rightY, [3] = rightX

//Robot specific stuff
boolean lastState = false; //Keeps track of when we go between enabled/disabled or vice versa
unsigned long lastUpdate = 0; //Keeps track of the last time (ms) we received data

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;


//Define robot outputs
int pwm01 = 5; //Digital Pin 5
int pwm02 = 6; //Digital Pin 6
Expand Down Expand Up @@ -53,8 +58,10 @@ void loop() {
/* This function's sole purpose is to receive data and shove it into the joystick_data byte array */
void xferdata()
{
if (Udp.available()) {
Udp.readPacket(joystick_data,PACKET_SIZE);
int packetSize = Udp.parsePacket();
if(packetSize)
{
Udp.read(joystick_data, PACKET_SIZE);
lastUpdate = millis();
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 78ee50c

Please sign in to comment.