Hi to all. Can anyone provide me with a simple routine to start controlling a DS1804 to slowly turn an LED on and off?
I get the error: "[DS1804] Wiper is at position 0. Additional clock pulses are ignored"
I use the tom-dudman library. Thank you.
Thank you.
No, the idea is not to use the DS1840 to control an LED. I am using a simulator that can do it, it is just a scheme to know if it works or not. A simple UP and DOWN control sketch. It would be enough for me to get out of the quagmire.
Sorry, I'm a very bad programmer. Although at the end of the design I will have to use the serial, what I really want is to see the DS1804 increase/decrement. I had already tried this sketch, I tried it again but I can't see it working in the simulator.
At the risk of sounding like an abuser, could you correct the loop so that it simply raises or lowers the wiper value?
Yes, but I didn't understand anything. I have corrected the alto777 example (from the library) and I have already gotten the DS1804 to work in the simulator. Again, thank you for your time and attention.
It took me a little while to understand that I had to replace i++ with i = i+100 to see that everything was going well. Houses of age, I'm going to be 75 years old...
#include <DS1804.h>
unsigned long wiperPin = A5; //const byte wiperPin = A5;
//DS1804( byte CSpin, byte INCpin, byte UDpin, unsigned long maxResistance );
DS1804 digipot = DS1804( 7, 5, 6, DS1804_FIFTY );
byte reading = 0;
unsigned long new_resistance = 0;
void setup() {
Serial.begin(9600);
Serial.println("Start ...");
digipot.setToZero();
}
void loop() {
//if ( Serial.available() > 0 ) {
for(unsigned long i = 0; i < 50000; i= i+100) {
new_resistance = i; //new_resistance = Serial.parseFloat();
digipot.setResistance(new_resistance);
delay(100); // give DS1804 time to change, and for analogue reading to settle
reading = analogRead(wiperPin);
delay(100); // give DS1804 time to change, and for analogue reading to settle
String wiperPositionText = "DS1804 Wiper at ";
Serial.println( wiperPositionText + digipot.getWiperPosition() );
String resistanceText = "DS1804 Resistance set to ";
Serial.println( resistanceText + digipot.getResistance() + " ohms (requested " + new_resistance + " ohms)" );
String wiperPinVoltageText = "Wiper pin voltage: ";
Serial.println( wiperPinVoltageText + 4.9*reading + " mV" );
}
//}
}