ok heres whats up, im trying to build arduino controlled firework launcher
im starting off with just the iosc test sketch witch controls 4 leds, 3 on/offs and 1 dimming
i uploaded the code with all of the right ip addresses and tried to use it
the leds dont do anything when i push the buttons, i opened the serial monitor and everytime i push a button it does get to the arduino so i know its not my ip addresses or anything, im new to arduino and microcontrollers in general, im thinking its somewhere else in the code since the rx light lights up everytime i push a button, can anyone help???
this is the code
#include "Ethernet.h"
#include "OSCClass.h"
#include "SPI.h"
#define LED_RED 2
#define LED_GRN 3
#define LED_YEL 4
#define LED_PWM 6
OSCMessage recMes;
OSCClass osc(&recMes);
byte serverMac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x3F, 0xF0 };
byte serverIp[] = { 192, 168, 2, 9 };
int serverPort = 10000;
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
char *topAddress="/ard";
char *subAddress[4]={ "/ledred" , "/ledgrn" , "/ledyel" , "/ledpwm"};
void setup() {
//for message logging
Serial.begin(19200);
// Ethernet.begin(serverMac ,serverIp);
Ethernet.begin(serverMac ,serverIp ,gateway ,subnet);
//setting osc recieve server
osc.begin(serverPort);
pinMode(LED_RED, OUTPUT);
pinMode(LED_GRN, OUTPUT);
pinMode(LED_YEL, OUTPUT);
pinMode(LED_PWM, OUTPUT);
digitalWrite(LED_RED, LOW); //LED OFF
digitalWrite(LED_GRN, LOW); //LED OFF
digitalWrite(LED_YEL, LOW); //LED OFF
digitalWrite(LED_PWM, LOW); //LED OFF
//osc message buffer clear
osc.flush();
}
void loop() {
//osc arrive check
if ( osc.available() ) {
logMessage(&recMes);
//toplevel address matching
if( !strcmp( recMes.getAddress(0) , topAddress ) ){
//second level address matching
if( !strcmp( recMes.getAddress(1) , subAddress[0] ) ){
red();
}
else if( !strcmp( recMes.getAddress(1) , subAddress[1] ) ){
green();
}
else if( !strcmp( recMes.getAddress(1) , subAddress[2] ) ){
yellow();
}
else if( !strcmp( recMes.getAddress(1) , subAddress[3] ) ){
pwm();
}
}
}
}
void red(){
if(recMes.getArgInt(0) == 1){
digitalWrite(LED_RED, HIGH); //LED_ON
}
else{
digitalWrite(LED_RED, LOW); //LED OFF
}
}
void green(){
if(recMes.getArgInt(0) == 1){
digitalWrite(LED_GRN, HIGH); //LED_ON
}
else{
digitalWrite(LED_GRN, LOW); //LED OFF
}
}
void yellow(){
if(recMes.getArgInt(0) == 1){
digitalWrite(LED_YEL, HIGH); //LED_ON
}
else{
digitalWrite(LED_YEL, LOW); //LED OFF
}
}
void pwm(){
byte value=(byte)recMes.getArgInt(0);
analogWrite(LED_PWM, 255-value);
}
// ********* utility ***********************************
void logMessage(OSCMessage *mes){
uint8_t *ip=mes->getIp();
//disp ip & port
Serial.print("from IP:");
Serial.print(ip[0],DEC);
Serial.print(".");
Serial.print(ip[1],DEC);
Serial.print(".");
Serial.print(ip[2],DEC);
Serial.print(".");
Serial.print(ip[3],DEC);
Serial.print(" port:");
Serial.print(mes->getPort(),DEC);
Serial.print(" ");
//disp adr
for(int i = 0 ; i < mes->getAddressNum() ; i++){
Serial.print(mes->getAddress(i));
}
//disp type tags
Serial.print(" ,");
for(int i = 0 ; i < mes->getArgNum() ; i++){
Serial.print(mes->getTypeTag(i));
}
Serial.print(" ");
//disp args
for(int i = 0 ; i < mes->getArgNum() ; i++){
switch( mes->getTypeTag(i) ){
case 'i': {
Serial.print( mes->getArgInt(i) );
}
break;
case 'f': {
Serial.print( mes->getArgFloat(i) );
}
break;
}
Serial.print(" ");
}
Serial.println("");
}
thanks