ds2406

Hello
I Researcher control multiple ds2406 but fails
this is how my attempt out

1 #include <OneWire.h>
21 #include <DS2406.h>
3 Aadress byte = {0x12, 0x35, 0x57, 0xB7, 0x00, 0x00, 0x00, 0x54};
4 bytes KKadress = {0x12, 0x8E, 0x94, 0x9D, 0x00, 0x00, 0x00, 0xAC};
5 OneWire Pow (2);
6 void setup (void)
7 {
8}
9 loop void (void)
10 {
11 OneWireSwitch OSW (& ow, Aadress);
12 // Turn on the switch.
13 osw.setSwitchState (true);
14 Delay (1000);
15 // Turn off the switch.
16 osw.setSwitchState (false);
17 Delay (1000);
18 ow.reset_search ();
19 OneWireSwitch OSW (& ow, KKadress);
20 // Turn on the switch.
21 osw.setSwitchState (true);
22 Delay (1000);
23 // Turn off the switch.
24 osw.setSwitchState (false);
25 Delay (1000);

get this wrong on line 19 error: redeclaration of ‘OneWireSwitch osw’
what am I doing wrong
would like to get help

utg_gartest.ino (670 Bytes)

Having not worked with the sensor (or library) itself, I can only go off what you’re reporting…

But OneWireSwitch appears to be a class, of which you’re trying to create two instances with the name “OSW” within the same scope.

Try to put both declarations at the beginning of loop, and have it read more like

OneWireSwitch osw(&ow, Aadress);
OneWireSwitch osw2(&ow,KKadress);
osw.setSwitchState(true);
delay(1000);
osw.setSwitchState(false);
delay(1000);
osw2.setSwitchState(true);
delay(1000);
osw2.setSwitchState(false);
delay(1000);

Although I would assume proper usage would be to have the two instances as global instead of local.

So it would look more like:

#include <OneWire.h>
#include <DS2406.h>

OneWireSwitch osw(&ow, Aadress);
OneWireSwitch osw2(&ow,KKadress);

void setup(){
}
void loop(){
  osw.setSwitchState(true);
  delay(1000);
  osw.setSwitchState(false);
  delay(1000);
  osw2.setSwitchState(true);
  delay(1000);
  osw2.setSwitchState(false);
  delay(1000);
}

Cover your final suggestion works. I did not test the top. it should also work out
many thanks from me, you made my life easier now