Hey thanks for the reply.
While I was waiting I came up with this:
//
//
//
// --a--
// f | | b
// |--g--| for reference
// e | | c
// --d--
// Define the LED digit patterns, from 0 - 9
// { a,b,c,d,e,f,g }
// Arduino pin: 2,3,4,5,6,7,8
int uparray []={
1,0,0,1,1,1,1,
0,0,1,0,0,1,0,
0,0,0,0,1,1,0,
1,0,0,1,1,0,0,
0,1,0,0,1,0,0,
0,1,0,0,0,0,0,
0,0,0,1,1,1,1,
0,0,0,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1
};
/*
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
*/
const int threshold = 200; // used to determine if receiver is receiving
int sensorPin = A0; // selects the analogue input pin for the IR transmitter/receiver
int sensorValue = 0; // varible that stores the value coming from the sensor
void setup() {
for (int t=2;t<9;t=t+1){
pinMode (t,OUTPUT);}
digitalWrite (pin9, 1); // controls dot - currently set off.
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin); // reads the value from IR transmitter/receiver
int k=0;
for (int t=0;t<10;t++){
for (int j=2;j<9;j++){
digitalWrite (j, uparray[k]);
if (sensorValue > threshold) {
k=k+1;
//k=k+1;
}
delay(2000);}
Serial.println(sensorValue);
}
}
This is my whole code.
I'm trying to increase the number on my display by 1 whenever my IR beam is broken. But with this code the display just goes a bit wonky.
Going to look into what you've posted to see what I can do. I'm quite a terrible coder so sorry if what I've posted is gobbledygook.