hi all, is it possible to communicate from one arduino to another via analog current? example: if i use PWM analogWrite as output on arduino board 1, give the two arduinos common ground and the read with analogRead on arduino board nr 2? i tried this but it doesnt work, analogRead value is stuck around 1000.... is it because of the way PWM works? should i insert a small capacitor to "even out" the PWM? best, jacob ps: the serial port is used, since im already talking with processing on one of the boards .. so i'd really like to do something very analog here
What about using either software serial or I2C ... ?
The capacitor should also work ... but more something like a Low Pass Filter using a resistor in series and a capacitor to the ground.
I had the same problem with my latest project. I needed 2 serial ports to run at fairly high speed. I used I2C which worked well.
Over i2c, connect both A4 & A5, common Vcc & GND, you'll need 2 x 1.8k resistors, use the wire library, master/slave examples can be located in the Arduino IDE
There's a bit of info about the method, here:-
analogWrite(), as you noted, sets the PWM output. PWM is either off or on, 0V or 5V. If the device on the other end is analog (or there are analog components like filter capacitors) this can be used as or turned into an analog signal that varies between 0V and 5V, but that isn't what comes out of the pin. I think the ATmega's ADC is SAR, which will grab a snapshot, but a delta-sigma ADC averages, so it may "smooth" your PWM into an analog signal (depending on the clock rates of the signal and ADC).
Now, if the receiving arduino uses
pulseIn(), then you can use that to convey digital information, and depending on the error in the system (PWM generation + transmission +
pulseIn() timing) you could conceivably use several different "levels", so you can convey a few bits of information in a single pulse (this system would have a bit rate higher than the baud rate, since there are multiple bits per time slice).