Input – output
I am trying to have the same pulses on pin PA7 as on PB12.
No pulses on PA7, what I doing wrong ?
int state = LOW;
int lastState = LOW;
void setup()
{
pinMode(PB12, INPUT);
pinMode(PB7, OUTPUT);
state = digitalRead(PB12);
}
void loop()
{
if (state == HIGH )
//if (state == HIGH && lastState == LOW)
digitalWrite (PB7, HIGH);
else
digitalWrite (PB7, LOW);
//delay(300);
}
// lastState – it gets set, but what changes this ? missing > lastState = State; < me duh
int state = LOW;
int lastState = LOW;
int State;
void setup()
{
pinMode(PB12, INPUT);
pinMode(PB7, OUTPUT);
state = digitalRead(PB12);
lastState = State;
}
void loop()
{
if (state == HIGH )
//if (state == HIGH && lastState == LOW)
digitalWrite (PB7, HIGH);
else
digitalWrite (PB7, LOW);
//delay(300);
}
if (state == HIGH )void setup()
{
pinMode(PB12, INPUT);
pinMode(PB7, OUTPUT);
}
void loop()
{
digitalWrite(PB7, digitalRead(PB12));
}
Now I will try with delay to achieve Phase Shift
void setup()
{
pinMode(PB12, INPUT);
pinMode(PB7, OUTPUT);
}
void loop()
{
// digitalWrite(PB7, digitalRead(PB12));
digitalWrite(PB7);
delay (30 );
digitalRead(PB12));
//delayMicroseconds(50);
//delay (30 ),
}
what does it mean “digitalWrite(PB7);”? what are you writing in PB7?!
and do you know that programming languages generally require parenthesis balancing? “digitalRead(PB12));”: you have one open parenthesis and 2 close ones..
finally, implementing a signal phase shifting is not trivial: it requires you store the read value in a buffer and read it after the delay is occurred but you should not use the delay() function, else you won’t be able to keep on reading the input while waiting for delay() finishes..

