so, i have the almost perfect version working fine on the breadboard. all the buttons work and the 7 segments are running a count from 0 to 8.
after I've spent hours soldering and testing connections, the soldered version is almost done... except, its just not quite right.
the buttons, leds, are all working... but i can't recreate the failure on the breadboard and everything seems to be wired correctly.
am i missing something obvious?
#include "LedControl.h"
//data, clock, load, 1 max7219
LedControl lc=LedControl(4,6,5,1);
#define BUTTON1 3
#define BUTTON2 8
#define REDLED 9
#define GREENLED 11
#define BLUELED 12
#define LED1SINK 2
#define LED2SINK 10
#define FACTION 7
int i = 0;
int faction = 'RES';
byte brightness = 8;
void setup(){
Serial.begin(9600);
lc.shutdown(0,false); // The MAX72XX is in power-saving mode on startup, we have to do a wakeup call
lc.setIntensity(0,brightness); // Set the brightness to a medium values
lc.clearDisplay(0); // and clear the display
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);
digitalWrite(BUTTON1, HIGH); // turn on pullup resistors
digitalWrite(BUTTON2, HIGH); // turn on pullup resistors
pinMode(FACTION, INPUT);
digitalWrite(FACTION, HIGH); // turn on pullup resistors
pinMode(REDLED, OUTPUT);
pinMode(GREENLED, OUTPUT);
pinMode(BLUELED, OUTPUT);
pinMode(LED1SINK, OUTPUT);
pinMode(LED2SINK, OUTPUT);
digitalWrite(LED1SINK, LOW);
digitalWrite(LED2SINK, LOW);
}
void loop(){
//show i on the digits
lc.setDigit(0,0,i, false);
lc.setDigit(0,1,i,false);
lc.setDigit(0,2,i,false);
// small delay for testing
delay(100);
//
Serial.print(" button1: "); Serial.print(digitalRead(BUTTON1));
Serial.print(" button2: "); Serial.print(digitalRead(BUTTON2));
Serial.print(" FACTION: "); Serial.print(digitalRead(FACTION));
Serial.print(" faction: "); Serial.print(faction);
// turn the leds on
digitalWrite(LED1SINK, LOW);
digitalWrite(LED2SINK, LOW);
// choose the colour
if (digitalRead(FACTION) == 0) faction = 'RES';
if (digitalRead(FACTION) == 1) faction = 'ENL';
if (faction == 'RES') {
digitalWrite (BLUELED, HIGH);
digitalWrite (GREENLED, LOW);
digitalWrite (REDLED, LOW);
}
if (faction == 'ENL') {
digitalWrite (GREENLED, HIGH);
digitalWrite (BLUELED, LOW);
digitalWrite (REDLED, LOW);
}
//increase i and return to 0 if too high
if (i<9) i++;
if (i>8) i=0;
Serial.print(i);
Serial.println();
}
