Pages: [1]   Go Down
Author Topic: Ardumote HD coding hardships  (Read 771 times)
0 Members and 1 Guest are viewing this topic.
Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
#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);
}
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
IPAddress iPhoneIP(192.168.252.156);
That isn't how you define an IPAddress. Did you look at the Ethernet examples?

Quote
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!
Why? That wasn't what the error message told you to do.
Logged

Illinois, US
Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That isn't how you define an IPAddress
Ah yes- I just didn't see that I had typed it in like that.  Old habits die hard.

Quote
That wasn't what the error message told you to do
The original error message did:
Quote
At first it said "in version 1.0 UDP was changed to EthernetUDP"

UPDATE:
I Emailed the Ardumote creator, and within two minutes he emailed me back the new code!  It is MUCH better, but I now have new hurdles.  I'll probably make a new post, because they are completely different issues.  Thanks for reading smiley
Logged

Pages: [1]   Go Up
Jump to: