Parking Sensor Project

Hi,

thank you for taking time to help me .

well my project is basically a parking sensor to help with parking lool all in anme

but any way I have come across a problem …my design is basically using a 555 timer to give 1.5kHz pulse signal to feed into to the shift register (Clock Input) and the shift register gets data from the arduino while the shift register outputs the data to LEDs

my main goal is to attach an LCD aswell to display the distance …the leds are going to be working by going from green to orange to red depending on distance …

I am writing my progam in block but to i am at point of testing data sent from arduino to shift register to light up the LEDs

I was thinking of using interrupts so that the program knows when the clock pulse is on the high side and then sends a high to the data input of the shift register …

I have the book by simon monk on programming the arduino (been very helpful) but I dont understand the interrupts bits page 112-114 what the hel is goFast ???

anyway I dont undertsand/know the best way for me to get the arduino to sense when the clock pulse has gone high so I can send a high data bit to the shift register …

Below is what I tried to do but didnt work :

void setup() {
// initialize digital pin 8 as an output.
pinMode(8, OUTPUT);
pinMode(7,OUTPUT);
}

// the loop function runs over and over again forever
void loop() {

int i = 0;
while ( i < 10)

{
digitalWrite(8, HIGH);
delay(0.000345);
digitalWrite(8, LOW);
delay(0.0000345);

digitalWrite(7, HIGH);
delay(0.000345);
digitalWrite(7, LOW);
delay(0.000345);

i ++;
}

Pin 8 is my data input to the shift register and pin 7 is reset for the shift register (basically clears it)

I have 4 LED connected and what i am trying to do is shift the data to the 1st LED (not the other 3) and then reset so it gives the illusion that only the first LED is on.

any help would be appreciated as my head is hurting from this :o :o

  delay(0.000345);

Did you read the documentation for the delay function?

I have the book by simon monk on programming the arduino (been very helpful) but I dont understand the interrupts bits page 112-114 what the hel is goFast

I don’t have the book.

 int i = 0;
  while ( i < 10)

Looks a lot like the start of a for loop. Why not use one?

Please, please use code tags when posting code.

ok i have changed it abit but stil not working and i am using while to help me try only ligh up the 1st LED

void setup() {
  // initialize digital pin 8 as an output.
  pinMode(8, OUTPUT);
  pinMode(7,OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  
  int i = 0;
  while ( i < 10000)
 
 {
  digitalWrite(8, HIGH);   
  delayMicroseconds(305);             
  digitalWrite(8, LOW);   
  delayMicroseconds(365);             
  
  digitalWrite(7, HIGH);   
  delayMicroseconds(305); 
digitalWrite(7, LOW);    
  delayMicroseconds(365);
  
  i ++;
 } 
}

Im starting to think the arduino cant do it properly by that i mean reading the clock signal and outputting a digital 1 every time the arduino read a high on the clock signal ...accurately

or i am being stupid an missing sumthin obvious ...

i am using while to help me try only ligh up the 1st LED

I don't understand that

but stil not working

Or that.

I have 4 leds connected to the 4 outputs of the shift register ..... I want the first led to stay on for 3-5 seconds so my thinking is get the arduino to send a logic 1 to the shift regeister on the high clock rise of my 555 timer (each clock rise from the 555 timer shifts the output of the shift register) ...so i was thinking of doing this with a while loop .....by this i mean that i have a frequency of 1.5kHz and 50% duty cycle .....so for one cycle it is 687.6microseconds . so since its 50% duty cycle, the high logic of the cycle last for 343microseconds .... so my pin 8 sends a high 1 for 305microseconds and goes low for the rest of the cycle . on the next clock pulse cycle i set output 7 high for one cycle as this is connected to my reset of the shift register and turns of the 1st led (clears all outputs) ....

if i am able to do this i am able to control all 4 leds in a way :o :confused:

my shift register

my 555 timer