hi. everytime i try to compile this in arduino IDE the programe crashes.
can someone help? <www.mitchellpage.com.au/wireless1.zip
//PROCESSING TO WIRING VERSION 4
char val; // variable to receive data from the serial port
int led = 0; // variable that keeps which led must be turn on next
int ledpinFour = 2;
int ledpinFive = 3;
int ledpinFour = 4;
int ledpinFive = 6;
int ledpinFour = 5;
int ledpinFive = 6;
int ledpinSix = 7;
int ledpinSeven = 8;
int ledpinEight = 9;
int ledpinNine = 10;
int viz2_state = 0;
int viz3_state = 0;
int vizOneActive;
int vizTwoActive;
int vizThreeActive;
void setup()
{
pinMode(ledpinOne, OUTPUT);
pinMode(ledpinTwo, OUTPUT);
pinMode(ledpinThree, OUTPUT);
pinMode(ledpinFour, OUTPUT);
pinMode(ledpinFive, OUTPUT);
pinMode(ledpinSix, OUTPUT);
pinMode(ledpinSeven, OUTPUT);
pinMode(ledpinEight, OUTPUT);
pinMode(ledpinNine, OUTPUT);
beginSerial(9600); // start serial communication at 9600bps
}
void loop() {
if ( serialAvailable() > 0) // if data is available to read
{
val = serialRead(); // read it and store it in 'val'
}
analogWrite(0, val);
//CHECK WHICH VALUE IS SENT
if( val == 'A' ){ //turn viz 1 on
vizOneActive = 1;
}
if ( val == 'B' ){ //turn viz 2 on
vizTwoActive = 1;
}
if ( val == 'C'){ //turn viz 3 on
vizThreeActive = 1;
}
if( val == 'D' ){ //turn viz 1 off
vizOneActive = 0;
}
if ( val == 'E' ){ //turn viz 2 off
vizTwoActive = 0;
}
if ( val == 'F'){ //turn viz 3 off
vizThreeActive = 0;
}
if ( val == 'G'){ //turn all vizualizations off
vizOneActive = 0;
vizTwoActive = 0;
vizThreeActive = 0;
turn_all_off();
}
//IF STATES ARE ON
if (vizOneActive == 1){
ledVizOne();
}
if (vizTwoActive == 1){
ledVizTwo();
}
if (vizThreeActive == 1){
ledVizThree();
}
//IF STATES ARE OFF
if (vizOneActive == 0){
turn_vizOne_off();
}
if (vizTwoActive == 0){
turn_vizTwo_off();
}
if (vizThreeActive == 0){
turn_vizThree_off();
}
delay(200);
}
/*=======================
VISUALIZATION FUNCTIONS
=======================*/
//VISUALIZATION 1
//function to continually turning on and off led's in cycle
void ledVizOne(){
turn_vizOne_off();
digitalWrite(led, HIGH);
led = (led + 1) % 3;
}
//VISUALIZATION 2
//function to turn all led's off in blinking fashion
void ledVizTwo(){
if (viz2_state == 0) {
turn_vizTwo_on();
viz2_state = 1;
}
else {
turn_vizTwo_off();
viz2_state = 0;
}
}
//VISUALIZATION 3
//function to turn leds off/on from outside in
void ledVizThree() {
turn_vizThree_off();
if (viz3_state == 0) {
digitalWrite(ledpinSeven, HIGH);
digitalWrite(ledpinNine, HIGH);
digitalWrite(ledpinEight, LOW);
viz3_state = 1;
}
else {
digitalWrite(ledpinSeven, LOW);
digitalWrite(ledpinNine, LOW);
digitalWrite(ledpinEight, HIGH);
viz3_state = 0;
}
}
/*=======================
OTHER FUNCTIONS
=======================*/
//function to turn OFF all the lights connected to digital pins 0 to 2
void turn_vizOne_off()
{
int i;
for(i=0; i<3; i++)
{
digitalWrite(i, LOW);
}
}
//function to turn OFF all the lights connected to digital pins 8 to 10
void turn_vizTwo_off()
{
int i;
for(i=8; i<11; i++)
{
digitalWrite(i, LOW);
}
}
// function to turn ON all the lights connected to digital pins 8 to 10
void turn_vizTwo_on()
{
int i;
for(i=8; i<11; i++)
{
digitalWrite(i, HIGH);
}
}
//function to turn OFF all the lights connected to digital pins 16 to 18
void turn_vizThree_off()
{
int i;
for(i=16; i<19; i++)
{
digitalWrite(i, LOW);
}
}
//function to turn OFF all the lights connected to digital pins 0 to 18
void turn_all_off()
{
int i;
for(i=0; i<19; i++)
{
digitalWrite(i, LOW);
}
}