Notifications
Clear all

4 Way Crossing Polarity  

Page 3 / 5
  RSS

John40131
(@john40131)
Estimable Member
Joined: 1 year ago
Posts: 100
2019-12-15 2:36 pm  

Hi Eric, tried removing line 226 and 324, got error so had to un-comment lines 233 and 239 as well, 3 screen shots the switches still do nothing but show up when moved except switch 1 that is staying at 1, also 2 of the servo,s are twitching 1 and 5 when enters a new loop, output on pins 1 thro 10 still same as before ...

I have added 3 screen shots..

Regards John

First Start
After 10 seconds all switches Forward
Another Loop with switches Backwards

 

One thing just noticed after 3rd loop the -1 at end of each Line 1A to 4A has changed to a 5 on each one..

This post was modified 10 months ago by John40131

ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 2:39 pm  

@john40131

Hi John, this is exactly why the boolean "availability" functions can make things manageable, by checking conflicts.

In my tests i used push buttons to "flip the switches" so a conflict, which would generate a call to raiseAlarm, could be used to beep a buzzer, light a red alarm LED, etc. Since the push button is only a temporary contact, there is no discrepancy between the switches and the layout.

But for 2-position physical switches, in case of conflict you end up with the switch being flipped and the turn point + polarities not been changed, so the physical switch is not "synchronized" any more with the layout. I'm not sure how to best manage that situation...

 

I'm available this afternoon, so if you want we can on-line chat on a discord server I own.  If so, just create a free account on https://discordapp.com/ and then tell me you're ready, I'll post an invite for you.

Eric


ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 2:40 pm  

@john40131

Hum, I just saw your last post, I'm reading...

Eric


ReplyQuote
John40131
(@john40131)
Estimable Member
Joined: 1 year ago
Posts: 100
2019-12-15 2:46 pm  

Hi Eric I thank you for the offer of chat on discord but not sure as computer in one room and layout in kitchen also could it be a long haul... dont want to upset your Sunday ..

John

On the link can you actually link to any program...as could link with Laptop I am using on Layout ...

This post was modified 10 months ago by John40131

ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 2:48 pm  

@john40131

Ouch ! I think you have a mess now...

You must not remove the #ifdef CROSSING_NOHARD lines like that if you want the code to maintain consistency.  What you can most easily do is to comment (with a //) the line with #define CROSSING_NOHARD, so that your digitalRead and digitalWrite are actually run.

Eric


ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 2:52 pm  

@john40131

Well, as you wish but I think direct discussion would make things much easier, and also enable me to share my screen to show you the code as I edit/test it

Eric


ReplyQuote
John40131
(@john40131)
Estimable Member
Joined: 1 year ago
Posts: 100
2019-12-15 2:55 pm  

@zeferby

No I havnt deleted just put // on these lines etc...

John

Did you see my other post about linking to my Laptop..

This post was modified 10 months ago by John40131

ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 3:27 pm  

@john40131

Let me try to explain the #define / #ifdef / #else / #endif ...

These are all what we call "pre-processor macros", which means that they are used by the compiler when reading the source code of a sketch to transform the source code before actually compiling it.

We can use them to remove/include whole blocks of code by just defining / un-defining a symbol : that enables a single sketch to be adapted to different uses.

Let's say we have a sketch like this :

 

No #define at all

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

#ifdef BLUE
Serial.println("I'm blue");
#endif

#ifdef RED
Serial.println("I'm red");
#endif

#ifdef YELLOW
Serial.println("I'm yellow");
#else
Serial.println("I'm DEFINITELY NOT yellow");
#endif
}

void loop() {
// put your main code here, to run repeatedly:

}

We have NOT defined any symbol with #define, so the actual code that is compiled is :

void setup() {
Serial.begin(9600);
Serial.println("I'm DEFINITELY NOT yellow");
}

void loop() {
}

...which you can verify by running the sketch above and checking the serial monitor output :

I'm DEFINITELY NOT yellow

 

BLUE

Now let's add a #define statement at the top for symbol BLUE :

#define BLUE

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

#ifdef BLUE
Serial.println("I'm blue");
#endif

#ifdef RED
Serial.println("I'm red");
#endif

#ifdef YELLOW
Serial.println("I'm yellow");
#else
Serial.println("I'm DEFINITELY NOT yellow");
#endif
}

void loop() {
// put your main code here, to run repeatedly:

}

We now have this actual resulting code :

void setup() {
Serial.begin(9600);
Serial.println("I'm blue");
Serial.println("I'm DEFINITELY NOT yellow");
}

void loop() {
}

and the output is now :

I'm blue
I'm DEFINITELY NOT yellow

 

BLUE + YELLOW

Let's now define BLUE and YELLOW, but not RED, like this :

#define BLUE
#define YELLOW

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

#ifdef BLUE
Serial.println("I'm blue");
#endif

#ifdef RED
Serial.println("I'm red");
#endif

#ifdef YELLOW
Serial.println("I'm yellow");
#else
Serial.println("I'm DEFINITELY NOT yellow");
#endif
}

void loop() {
// put your main code here, to run repeatedly:

}

The resulting code is now :

void setup() {
Serial.begin(9600);
Serial.println("I'm blue");
Serial.println("I'm yellow");
}

void loop() {
}

and the output is :

I'm blue
I'm yellow

 

NOT YELLOW

Now let's say we don't want to be yellow : we can comment out the #define for that symbol to go back to "pure blue" like this :

#define BLUE
//#define YELLOW

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

#ifdef BLUE
Serial.println("I'm blue");
#endif

#ifdef RED
Serial.println("I'm red");
#endif

#ifdef YELLOW
Serial.println("I'm yellow");
#else
Serial.println("I'm DEFINITELY NOT yellow");
#endif
}

void loop() {
// put your main code here, to run repeatedly:

}

The resulting code is back to the "pure blue" again :

void setup() {
Serial.begin(9600);
Serial.println("I'm blue");
Serial.println("I'm DEFINITELY NOT yellow");
}

void loop() {
}

with the corresponding output :

I'm blue
I'm DEFINITELY NOT yellow

 

 

So to "switch on/off" our yellow color aternative (single line) codes, we just have to #define or un-define the YELLOW symbol

Eric


dorsay liked
ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 3:37 pm  
Posted by: @john40131

Did you see my other post about linking to my Laptop..

Sorry I just saw that.

Discord can be used, as long as you have an Internet connection :

  • simply with a recent enough web browser
  • or by installing the windows app
  • it is also available on mobiles

Of course if we want to have a voice chat you need a microphone+speaker, but if you don't we can still text-chat in an efficient manner, and share screens/windows

 

Eric


ReplyQuote
John40131
(@john40131)
Estimable Member
Joined: 1 year ago
Posts: 100
2019-12-15 3:46 pm  

Thanks for your help yet again, I will leave today as I was on my own but family and grandson just got back from Trafford Centre so will be mayhem in this house I will look through your last message and see what You suggested..

John


ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-15 3:59 pm  

Ok @john40131

FYI here is a rather old (2016) but still mostly accurate presentation of what can be done with Discord (the screen/app sharing feature did not exist yet in 2016 so there is no mention of it in the video).

 

Eric


ReplyQuote
John40131
(@john40131)
Estimable Member
Joined: 1 year ago
Posts: 100
2019-12-15 7:54 pm  

Hi Eric, I think I under stand the #ifdefine , but  the #ifdefine CROSSING_NOHARD in the void setup and what does this do.

Also thinking of live chat and probably next Saturday at about 2.00pm UK time would be fine but will confrm as depends what family are doing so I have peave,.

Also was think of maybe SKYPE is that a better option I aleardy have an account but Camera doesnt seem to function properly,  so can get cheap one off ebay, could have a live Chat and Video, I'll leave that up to you.

I can set up my main computer with chat and Video and use Laptop connected to Layout next to me, which has Arduino IDE and sketch so you can see exactly what is happening .

Regards John

PS.. another thought has I have 2 screens on main computer can run USB to Layout from this maybe easier to change any code..

This post was modified 10 months ago by John40131

ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-16 12:36 am  
Posted by: @john40131

Hi Eric, I think I under stand the #ifdefine , but  the #ifdefine CROSSING_NOHARD in the void setup and what does this do

Huh, that seems to mandate more explanations i guess

Posted by: @john40131

next Saturday at about 2.00pm UK time would be fine

As of now, next saturday afternoon is ok for me, but i think we'll both want to confirm this before.

Posted by: @john40131

Also was think of maybe SKYPE is that a better option

(cough! cough!) I banished Skype some time after Micro$oft bought them and began spamming me, after multiple years of using Skype with my chinese clients.  M$ was the end of Skype for me, sorry...

This is actually the main reason I started using Discord, and I really have no regret, especially as I am now able to taylor chat servers and manage authorization settings exactly as I wish of that platform - mostly for free, though I am also a "subscriber" for several "premium" features.

Posted by: @john40131

Camera doesnt seem to function properly

No worry, we don't need to see each other's ugly face ? !

What is more important is being capable of efficient bi-directional text-chat without spamming the forums (even better, if possible, combined text with voice-chat), and I can show you my screen as we go over pieces of code for the "theoretical" aspect.   If you are also able to show me your own Arduino IDE+SerialMonitor as you run the sketches, then it's all the best : we could alternately share our screen or app for the other to watch.  So if you have a machine with mic+speakers, or a headset, it would be perfect, but if the machine linked to the Arduino is Internet-capable, then it would be able to run Discord, even without any sound.

Also, exchanging files (sketches, pictures, etc...) on this type of chat platform is as simple as drag-and-drop.

 

Reminder : if you want to ensure i am aware of a post here, include @zeferby somewhere in it, so I get an email from the forums about it.

Eric


ReplyQuote
John40131
(@john40131)
Estimable Member
Joined: 1 year ago
Posts: 100
2019-12-16 1:51 pm  

@zeferby

Thats Great Eric, I will confirm if okay on Friday for Saturday.

Also I have watched the video on Discord but you may have to tell me how I can let you see serial monitor, is it possible to access my computer so can edit, I know some companies have the abillity to open programs, I have used Sage accounts and Quickbooks and if you have problems the company can access your system to trouble shoot...

Reagards John


ReplyQuote
ZeFerby
(@zeferby)
Reputable Member
Joined: 1 year ago
Posts: 380
2019-12-16 4:53 pm  

@john40131

let's first have an online chat+share saturday, and then we'll see if we have a real need for remote control.

One-on-One Screen/window sharing is done within a voice chat in Discord :

(there is also a way to share a screen/window to all users connected to a voice channel)

Eric


ReplyQuote
Page 3 / 5