if (lightReset == HIGH)
Is there any possible way for the pin number to equal HIGH? Time to reread the previous post, and actually pay attention to it!
if (lightReset == HIGH)
Is there any possible way for the pin number to equal HIGH? Time to reread the previous post, and actually pay attention to it!
Ok here is a diagram i made of my breadboard Please help i need this project done ASAP and code or code ideas would be greatly appreciated thanks!
Uploaded with ImageShack.us
You've given lightReset the value 2.
How can that ever == HIGH ( aka 1)?
Please help i need this project done ASAP
That's not our problem.
The Led still won't turn on. when i changed it to this
if (lightReset == 1)
The Led still won't turn on. when i changed it to this
2 is STILL not 1!
Look, lightReset is a pin number. Presumably it relates to the switch. Use digitalRead() to get status of the pin, and use the result in your if statement.
Here is most resent code and the led will not come on at all. Is there a different way to program this that would work better. Thanks
int lightPin = 11;//my led
int lightBright = A1;//my pot to controll the brightness
int lightTime = A2;//my pot to controll the time it is on
int lightReset = 2;//my tact switch to turn on the light
int timeA;
int bright;
int x;
int timeB;
int button;
void setup()
{
pinMode(lightPin, OUTPUT);
pinMode(lightBright, INPUT);
pinMode(lightTime, INPUT);
pinMode(lightReset, INPUT);
}
void loop()
{
timeA = analogRead(lightTime);
timeB = map(timeA, 0, 1023, 10000, 120000L);
button = digitalRead(lightReset);
if(button, 1)
{
for(x = 0; x <= timeB; x++)
{
bright = analogRead(lightBright);
analogWrite(lightPin, bright);
delay(1);
}
}
else
{
analogWrite(lightPin, 0);
}
}
if(button, 1)
Not sure about that.
Quite easy, that one is the same as if(true) ]![]()
Ok i fixed that problem and I can adjust the brightness when ever i want but now how do i get it so when ever i press the tact switch when the led is on the if statement repeats it's self and thanks for the fast relpy.
Ok i fixed that problem and I can adjust the brightness when ever i want but now how do i get it so when ever i press the tact switch when the led is on the if statement repeats it's self and thanks for the fast relpy.
You fix it be telling us what you complete homework assignment is.
You don't seem to have a complete set of requirements. If you do, you are trying to implement them one at a time, instead of developing a structure that allows for implementing them all.
We can't help you band-aid requirements on. We can help if we know ALL the requirements.
This is not a homework assignment. I had an idea to I wanted to prototype it.
Here is a basic set up of what i want it to do.
I press the tact switch and the light turns on for how ever long one pot is set and for how bright the other pot is set and when ever the tact switch is hit again (with or without the led on) the led will stay on till the tact switch is hit again or tell the time runs out.
Your requirements are still too vague. Break them down into simpler statements:
One pot is used to define brightness.
One pot is used to define on time.
Press the switch to turn the LED on for the defined time at the defined brightness.
Now, you need to define what pressing the switch again does if the LED is on, and if the LED is off.
You can't just wave your hands and say that it does not matter whether the LED is on or off when the action to perform is "the LED stays on until the switch is pressed again or until the time runs out".
Pressing the switch the first time starts a timer running. That is a transition from the "Nothing happening" state to the "Light is on; timer is running" state occurs.
When the timer runs out, a transition from the "Light is on; timer is running" state occurs, to the "Nothing happening" state.
Pressing the switch while in the "Light is on; timer is running" state causes a transition to a third state that you have not adequately defined. Nor have you been specific enough about what happens at the transition or exactly what conditions cause that new state to be exited and what state you go to next.
Draw some circles on a piece of paper. Write a state name in each circle. Draw some arrows between the circles (the states) and label them with what causes a transition (switch press, timer expired, etc.).
Start with the two states that are well defined - "nothing happening" and "LED is on; timer is running". Then, add the new state(s) and transitions.
I think you'll see that it makes a great deal of difference if the LED is currently on or not when the switch is pressed.
Jot notes inside each circle that indicate things like "LED is on" or "LED is off". Things the Arduino does go inside the circles. Things YOU do (press a switch) go outside the circles, labeling the arrows that connect the circles.
i hope this helps clear thing up.
the photo is too big to embed
Hey, that's almost good enough to read.
But not quite.
You have to click on the image to get it bigger
That's what I would've expected.
But the reality is - it doesn't.
Agreed. Clicking on zoom takes me to an 'upload files' page.
Try this one, sorry.
Can you see the text