I am pretty new to Arduino and am trying to figure out how to connect 2 pins, then output information (or PWM) from one and input it on the other pin.
So far I tried this but it does only show the same numbers (~500 to 440), even if I disconnect the pins:
int pin_out = 9;
int pin_in = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
analogWrite(pin_out, 255);
delay(500);
Serial.println(analogRead(pin_in));
}
Edit:
I managed to measure some signal with this code:
int pin_out = 9;
int pin_in = 0;
void setup() {
Serial.begin(9600);
pinMode(pin_out, OUTPUT);
pinMode(pin_in, INPUT);
}
void loop() {
analogWrite(pin_out, HIGH);
Serial.println(pulseIn(pin_in, HIGH));
delay(500);
analogWrite(pin_out, LOW);
Serial.println(pulseIn(pin_in, HIGH));
delay(500);
}
The signal ranges from 0 to 9. What am I measuring?
analogRead
. – gre_gor