So, I have been going through as many tutorials as I can manage in the free time I can scrounge up, and I have hit a small roadblock in my progress.
The IDE is having problems with my shiftout lines, and I am not sure how to fix it.
If you are curious- this program listens to packets sent over wifi from my iPad, reads them, then runs specific pumps to dispense booze. At least, that's what I WANT to happen. All the communication stuff works fine... until I try to send out data through a couple shift registers...
Any suggestions?
Here is the code:
#include <SPI.h> // for Arduino later than ver 0018
#include <EthernetUdp.h> // UDP library from bjoern@cs.stanford.edu
#include <Ethernet.h>
////////// NETWORK INFO ////////////////
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xDB, 0x50 }; //Set your Ethernet Shield's MAC address here - make sure you replace the ZZs with your shield's values!
byte ip[] = { 192, 168, 1, 5 }; // Set your shield's desired IP address here - check your network for configuration detail
unsigned int localPort = 7777; // local port to listen on (set this the same as Port # on Ardumote Params Screen)
IPAddress iPhoneIP(192, 168, 2, 3); //Set the iPhone/iPod/iPad's IP address to send messages back to Ardumote...
unsigned int iPhonePort = 7777; //Set the Port # of the message table you configured in Ardumote (default is 7777)...
///////// Pin Assignments /////////////////
int data = 2; //Begin Shift register integers
int clock = 3;
int latch = 4;
int ledState = 0;
const int ON = HIGH;
const int OFF = LOW; //end shift register integers
//begin drink integers
byte vodka1st = 0x1;
byte vodka2nd = 0x0;
byte rumlt1st = 0x2;
byte rumlt2nd = 0x0;
byte tequila1st = 0x4;
byte tequila2nd = 0x0;
byte whiskey1st = 0x8;
byte whiskey2nd = 0x0;
byte gin1st = 0x10;
byte gin2nd = 0x0;
byte amarretto1st = 0x20;
byte amarretto2nd = 0x0;
byte tripsec1st = 0x40;
byte tripsec2nd = 0x0;
byte kahlua1st = 0x80;
byte kahlua2nd = 0x0;
byte midouri1st = 0x0;
byte midouri2nd = 0x1;
byte brandy1st = 0x0;
byte brandy2nd = 0x2;
byte vermouth1st = 0x0;
byte vermouth2nd = 0x4;
byte cran1st = 0x0;
byte cran2nd = 0x8;
byte sour1st = 0x0;
byte sour2nd = 0x10;
byte cola1st = 0x0;
byte cola2nd = 0x20;
byte tonic1st = 0x0;
byte tonic2nd = 0x40;
byte grenad1st = 0x0;
byte granad2nd = 0x80;
byte orange1st = 0;
byte orange2nd = 0;
byte pine1st = 0;
byte pine2nd = 0;
byte syrup1st = 0;
byte syrup2nd = 0;
byte rumdk1st = 0;
byte rumdk2nd = 0;
byte sprite1st = 0;
byte sprite2nd = 0;
byte ginger1st = 0;
byte ginger2nd = 0;
byte water1st = 0;
byte water2nd = 0;
byte motorsoff = 0x0;
///////////////// UDP Variables //////////////////
// buffers for receiving and sending data
char packBuff[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
/////////////////////////////////////////////////
EthernetUDP Udp;
void setup() {
//start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort); // Setup UDP on port defined earlier
Serial.begin(9600); // Start serial com @ 9600 bps (baud)
// set pins for shift register
pinMode(data, OUTPUT); //begin shift register pinmodes
pinMode(clock, OUTPUT);
pinMode(clock, OUTPUT); //end shift register pinmodes
}
void loop() {
//int pwmVal; //integer holding the PWM values for later use NOT NEEDED!!
// the following looks for a packet and then reads it and prints it after subtracting 8
int packetSize = Udp.parsePacket(); // note that this includes the UDP header
if(packetSize) { //if a packet is there...
packetSize = packetSize - 8; //subtract the 8 byte header
Serial.print("Packet size: ");
Serial.println(packetSize); // ... and then print it to the monitor
// the following will read the packet into packetBuffer and get the senders IP addr and port number
Udp.read(packBuff,UDP_TX_PACKET_MAX_SIZE);
Serial.println("Message: ");
Serial.println(packBuff);
//////////////////////// PWM Assignments DELETED! /////////////////////////////////////
if (packBuff[0]== 'G' && packBuff[1]=='B' && packBuff[2]=='D' && packBuff[3]=='L');
{
digitalWrite(latch, 0);
shiftOut(data, clock, vodka1st); // it has a big problem with all my shiftout lines
shiftOut(data, clock, vodka2nd);
digitalWrite(latch, 1);
delay(3000);
digitalWrite(latch, 0);
shiftOut(data, clock, motorsoff);
shiftOut(data, clock, motorsoff);
digitalWrite(latch, 1);
Udp.beginPacket(iPhoneIP,iPhonePort);
Udp.write("Vodka poured"); // Send Message back to iPhone
Udp.endPacket();
}
}
delay(20);
}
void updateLEDs(int value)
{
digitalWrite(latch, LOW); // set latch low
shiftOut(data, clock, MSBFIRST, value);
digitalWrite(latch, HIGH); // reset latch back to high
}
Please don't blast me too bad... I'm doing my best!
EDIT: The IDE lists "/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h: In function 'void loop()':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:111: error: too few arguments to function 'void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t)'
barbotgroundup:122: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:111: error: too few arguments to function 'void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t)'
barbotgroundup:123: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:111: error: too few arguments to function 'void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t)'
barbotgroundup:127: error: at this point in file
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:111: error: too few arguments to function 'void shiftOut(uint8_t, uint8_t, uint8_t, uint8_t)'
barbotgroundup:128: error: at this point in file "
as the errors. Ew, right?