Arduino UNO SPI Operation

I'm hoping this is the correct area to post this question. If not, please tell me where this should be posted. Thank You in advance for any help.
I am attempting to build a unit to test and program a three color (R-G-B) LED board using SPI portion of an Arduino UNO R3. Basically, if a certain color button is depressed, the slave select (SS) lines goes low, then it sends the program to a DAC on the board. The trigger then turns on the appropriate color for ~2 seconds. None of my outputs are being triggered. I've watched every video (YouTube) and searched every board online for an answer. Can anyone point me at where I made my mistake? I'm not a programmer by any stretch of the term and freely admit this.
My code thus far;

#include<SPI.h> //SPI library
#include <InputDebounce.h> //debounce library

const int redButton = 1; //red switch
const int grnButton = 2; //green switch
const int bluButton = 3; //blue switch
const int slaveSelect = 10; //slave select
const int redTrigger = 5; //red trigger
const int grnTrigger = 6; //grn trigger
const int bluTrigger = 7; //blu trigger

#define RMP 0x13ff //red medium power
#define RFP 0x17ff //red full power
#define GMP 0x53ff //green medium power
#define GFP 0x57ff //green full power
#define BMP 0x93ff //blue medium power
#define BFP 0x97ff //blue full power

void setup ()
{
pinMode (redButton, INPUT);
pinMode (grnButton, INPUT);
pinMode (bluButton, INPUT);
pinMode (slaveSelect, OUTPUT);
pinMode (redTrigger, OUTPUT);
pinMode (grnTrigger, OUTPUT);
pinMode (bluTrigger, OUTPUT);

digitalWrite (redTrigger, HIGH); //red trigger set HI
digitalWrite (grnTrigger, HIGH); //grn trigger set HI
digitalWrite (bluTrigger, HIGH); //blu trigger set HI
digitalWrite (slaveSelect,HIGH); //turn off DAC programming

SPI.begin; //begin spi mode
}

void loop() //begin red read and program
{
if (redButton == HIGH); //begin red IF
{
digitalWrite (slaveSelect,LOW); //program DAC
SPI.transfer (RMP); //DAC red data
delay(10);
digitalWrite (slaveSelect,HIGH); //stop DAC programming
digitalWrite (5, LOW); //send red trigger
delay (2000);
digitalWrite (5, HIGH); //turn off red trigger
}

if (grnButton == LOW); //begin green IF
{
digitalWrite (slaveSelect,LOW); //program DAC
SPI.transfer (GMP); //DAC green data
delay(10);
digitalWrite (slaveSelect,HIGH); //stop DAC programming
digitalWrite (6, LOW); //send green trigger
delay (2000);
digitalWrite (6, HIGH); //turn off green trigger
}

if (bluButton == LOW); //begin blue IF
{
digitalWrite (slaveSelect,LOW); //program DAC
SPI.transfer (BMP); //DAC blue data
delay(10);
digitalWrite (slaveSelect,HIGH); //stop DAC programming
digitalWrite (7, LOW); //send blue trigger
delay (2000);
digitalWrite (7, HIGH); //turn off blue trigger
}
}

what DAC are using? if you can please share its datasheet.

Your sketch does not work as expected, the RMP, GMP and BMP values are ALWAYS transmitted to the DAC with EVERY loop run, regardless of whether one of the buttons is pressed or not.
Reason: behind all queries of the buttons - if (xxxButton == HIGH); is the semicolon ';' which makes the query ineffective on the following code block.

1 is always equal to HIGH (1)
2 is never equal to LOW (0)
3 is never equal to LOW (0)

If you want to read the input pins, you have to say so:

if (digitalRead(redButton) == HIGH) //begin red IF
if (digitalRead(grnButton) == LOW) //begin green IF
if (digitalRead(bluButton) == LOW) //begin blue IF

ERROR: Your 'if' statements contain only a ';'

if (redButton == HIGH) ; //begin red IF
if (grnButton == LOW) ; //begin green IF
if (bluButton == LOW) ; //begin blue IF

Remove those ';' if you want the 'if' to control the statement BELOW the 'if'.

No!
if (digitalRead(redButton) == HIGH) { Code to be executed when the condition is fulfilled }//begin red IF
if (digitalRead(grnButton) == LOW) { Code to be executed when the condition is fulfilled } //begin green IF
if (digitalRead(bluButton) == LOW) { Code to be executed when the condition is fulfilled } //begin blue IF

always WITHOUT ";"

Yes. I saw that and corrected it.

The above line does... absolutely nothing! It should be:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.