I have already started the project based off another forum -
http://forum.arduino.cc/index.php/topic,151317.0.html
i need help with the code the one that was provided I believe is incorrect.
if anyone can help me with a code that would be wonderful.
im leaving out the buzzer which i dont need and my sensor is a Hc-sr04 different from the one that was stated in said forum. and for the power supple i am using a 3.3v/3.5v power supply


this is apparently the code that was provided just from looking at it i feel its missing alot or am i wrong
int sensorPin=0;
double segment=0;
double sensorVoltage=0;
void setup()
{
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
Serial.begin(9600);
}
void sevenSegment(int number)
{
switch(number)
{
case 0:
PORTD=0b01000000; // 0
PORTB=0b00000000;
break;
case 1:
PORTD=0b11111000; // 1
PORTB=0b00000000;
break;
case 2:
PORTD=0b00100100; // 2
PORTB=0b00000000;
break;
case 3:
PORTD=0b00110000; // 3
PORTB=0b00000000;
break;
case 4:
PORTD=0b10011000; // 4
PORTB=0b00000000;
break;
case 5:
PORTD=0b00010010; // 5
PORTB=0b00000010;
break;
case 6:
PORTD=0b00000010; // 6
PORTB=0b00000010;
break;
case 7:
PORTD=0b01111000; // 7
PORTB=0b00000000;
break;
case 8:
PORTD=0b00000000; // 8
PORTB=0b00000000;
break;
case 9:
PORTD=0b00011000; // 9
PORTB=0b00000000;
break;
default:
// nothing
}
}
void loop()
{
sensorVoltage=analogRead(sensorPin);
segment=(0.018)*sensorVoltage-(0.2);
delay(500);
sevenSegment(segment);
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
Yes, you are correct. That code doesn't fit the schematic at all, and doesn't do anything but display digits on a seven segment.