Hopefully this isn't the wrong part of the forum to ask about my problem - I hardly use it.
As of a few days ago my serial port (it seems) has been acting up: before, I could attach an LDR (with 10k ohm voltage divider) with no problem and see the light level in the serial monitor with some basic code. Ever since I tried making this circuit, it hasn't worked properly and when I am sure everything is properly connected the serial monitor just reads 0. I'm thinking that it's a communication problem between the board and the computer as when I try a simple LDR program on another board nothing comes up on the serial monitor, though that wouldn't explain the lack of expected results when I plug it into the mains.
What I want to happen: Arduino receives LDR (10k ohm resistor with voltage divider) data and displays it on a scale of 0 to 9 on the 1 digit 7 segment display (1k ohm resistor, common anode) I have connected. I can confirm the 7SD is working fine, as it too reads 0 only. (I know the code could be more efficient but I couldn't be bothered.)
I have included a photo of the Arduino with breadboard circuit and serial monitor, but say if you need a wiring diagram for clarity.
Your help would really be appreciated!
Here's the code:
#include <SevSeg.h>
SevSeg sevseg;
int LDRval = 0;
int LDRpin = A0;
void setup(){
byte numDigits = 1;
byte digitPins[] = {};
byte segmentPins[] = {6, 5, 2, 3, 4, 7, 8, 9};
bool resistorsOnSegments = true;
Serial.begin(9600);
byte hardwareConfig = COMMON_ANODE;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
}
void loop(){
LDRval = analogRead(A0);
Serial.println(LDRval);
delay(200);
if(LDRval >= 900) {
sevseg.setNumber(9);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 900 && LDRval >= 800) {
sevseg.setNumber(8);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 800 && LDRval >= 700) {
sevseg.setNumber(7);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 700 && LDRval >= 600) {
sevseg.setNumber(6);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 600 && LDRval >= 500) {
sevseg.setNumber(5);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 500 && LDRval >= 400) {
sevseg.setNumber(4);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 400 && LDRval >= 300) {
sevseg.setNumber(3);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 300 && LDRval >= 200) {
sevseg.setNumber(2);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 200 && LDRval >= 100) {
sevseg.setNumber(1);
delay(250);
sevseg.refreshDisplay();
}
if(LDRval < 100 && LDRval >= 0) {
sevseg.setNumber(0);
delay(250);
sevseg.refreshDisplay();
}
}