Hello everyone,
I downloaded the iPad app "Ardumote HD" (www.SamratAmin.com/Ardumote.html) and picked up an ethernet shield. I would like to use my iPad to light an LED connected to pin 2 on my Uno. The ethernet shield is plugged into the ethernet port of my laptop, which is on a public wifi network with the iPad.
Almost immediately I hit a roadblock. Going to the Ardumote tutorial website (http://samratamin.com/Ardumote_Tutorial.html) I was quick to discover the link to the example code... isn't even a link at all! Scouring the web for another instance of the code, I stumbled across a post that contained a version of it by luck.
Inputting the code, it wouldn't compile (of course, lol) At first it said "in version 1.0 UDP was changed to EthernetUDP"
So I changed the line that contained udp to EthernetUDP, and I also loaded the ethernet library at the top because it wasn't there originally.
NOW it's saying "Expected unqualified-id before "." token" and I am unsure of how to rectify the situation. It highlights the line "EthernetUDP.begin(localPort);" as the issue, which is the same line I changed from Udp to EthernetUDP. Any help will be greatly appreciated!
Here is what I have right now:
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>
#include <SPI.h>
#include <Udp.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xDB, 0x50 };
byte ip[] = { 169,254,130,77 };
//byte gateway[] = { 192,168,0,1 };
//byte subnet[] = { 255,255,255,0 };
unsigned int localPort = 7777;
IPAddress iPhoneIP(192.168.252.156);
unsigned int iPhonePort = 7777;
int LED_Pin = 2;
byte remoteIp[4];
unsigned int remotePort;
char packBuff[UDP_TX_PACKET_MAX_SIZE];
void setup() {
Ethernet.begin(mac,ip);
EthernetUDP.begin(localPort); //This is where the program is identifying a problem
Serial.begin(9600);
pinMode(LED_Pin,OUTPUT);
}
void loop()
{
int pwmVal;
int packetSize = Udp.available(); //should I change this one to EthernetUDP as well?
if(packetSize)
{
packetSize = packetSize - 8;
Serial.print("Packet size: ");
Serial.println(packetSize);
Udp.readPacket(packBuff,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort); //does this need EthernetUDP too?
Serial.println("Message: ");
Serial.println(packBuff);
pwmVal = (packBuff[3] - '0')*100 + (packBuff[4] - '0')*10 + (packBuff[5] - '0');
if (packBuff[0] = 'P' && packBuff[1]=='W' && packBuff[2]=='M')
analogWrite(LED_Pin,pwmVal);
Serial.println("PWM on Pin 2");
}
else if (packBuff[0] = 'P' && packBuff[1]=='2' && packBuff[2]=='H')
digitalWrite(LED_Pin,HIGH);
Serial.println("LED ON");
else if (packBuff[0] = 'P' && packBuff[1]=='2' && packBuff[2]=='L')
{
digitalWrite(LED_Pin,LOW);
Serial.println("LED OFF");
}
}
delay(20);
}