Double check code

Hi everyone.

I want to switch Led on and off on seperate times, of which a lot of them are 1 seconds.

English is not my primary languege. I am struggling to understand the examples properly. Would someone check if my code is correct, and help me to re-use the timer (Count1) further in the program. I dont want to use delay.

int led = 8; int Count1=1000UL; int Count2=1000UL;

void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT);


void loop() { if(led, !HIGH) digitalWrite(led, HIGH); unsigned long(Count1); digitalWrite(led, LOW); unsigned long(Count1);


if(led, !HIGH)

The comma operator is NOT what you want to be using here.

8 will never equal HIGH.

 unsigned long(Count1);

I have no clue what you think this is doing. Whatever it is you think it is doing, that is NOT what it is doing.What it is doing is NOTHING.


What do you want to do? have you fixed the problems already pointed-out?

Welcome to the forum.

"Would someone check if my code is correct" You can do this by running the sketch. Try it and tell us what you get.

Have you looked at the BWD BlinkWithoutDelay example found in the IDE? .

You can do this by running the sketch.

Not when it won't even compile. (Or if.) (No, when is correct.)

Hopefully they would come back and say it doesn’t compile, then we would know they know how to use the compile button.


Hopefully they would come back and say it doesn't compile

Well, since the number of { and the number of } don't match, that should be obvious. But, your point is still valid.

It did compile, But as you said did nothing.

All i want to do is have the led go on and off on different times, and stopping at the end. But i do not want to use delay. Its just for my own exercise.

Thank you for your input so far.

But i do not want to use delay.

Have a look at the blink without delay example provided in the IDE.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

You don't need your code checked, you don't need one error at a time fixed until you "kind of" get it: you need to learn the basics of the C++ language. Google "C++ tutorial" and do the first few chapters.

The ardiino platform has a couple of differences to plain C++ (we have a loop() and setup() instead of main(), we use Serial.out instead of stdout), but a regular C++ tutorial will get you past the kinds of difficulties that your post indicates you are having.

Do any one of these tutorials until you have variables, statements, and functions covered. You can stop once the tutorial starts discussing how to use classes and the 'new' and 'delete' operators.