Need Help. Automated blinds using 28byj-48 + ULN2003 + LDR-sensor + UNO-board

Hey,
Noobie here!

I have a project where i am making automated blinds with arduino UNO board, 28byj-48 stepper motor, ULN2003 and LDR-sensor.

Idea is for sun to shine on the LDR-sensor, which controls the motor. How can i impliment treshold values to my code so that it can do the following:

Blinds turn 100 degrees CW when sun shines (our sensor value is <50)
Blinds return to middle position when it is cloudy (sensor value 50-180)
Blinds turn 100 degrees CCW when its dark (sensor value is 200+)

TOIMII.EL_.KOSKE.ino (4.79 KB)

So what is wrong with the example you posted?

Key questions:

  • What DOES it do?
  • What doesn't it do what you do expect it to do?
  • What do you want it to do more?

And a problem for later but something you probably want to address, you want some hysteresis / delay / low pass filtering on the input. Otherwise i think you'll become crazy when the sun is changing the slightest bit from 49 to 50 etc.

With the current code:

the motor turns CW forever when value is 1-100 (so any value in this range keeps this movement)

The motor is still between values 101 and 200 (so any value in this range keeps this movement)

The motor turns CCW in every value that is over 200 (so any value in this range keeps this movement)

i want to stop the movement after certain time or certain steps because otherwise the blinds will break

Okay, I see a lot of improvement but let's start with this for the sake of learning. For the most precision let's count steps. Where and how would you be able to count steps?

PS What is that spare ",2" doing here??

delay(motorSpeed),2;

Code: [Select]
delay(motorSpeed),2;

This is the delay time set when the rotors etc. insides of the motor turn from pin to pin. I have changed this value higher and this slows the motor.

For the step counting....that is my question to the forum. How can i impliment a code that counts steps. How to use that info to stop the motor after certain amount of steps are done.

Do i need to put somekind of "Serial.printin" for the motor step counting?

I have made my code from many other codes. I have mixed it to the result i have posted here.

Thaxu:
Code: [Select]
delay(motorSpeed),2;

This is the delay time set when the rotors etc.

No it's not :wink: That's what the variable 'motorSpeed' does. I asked about that ",2" :wink:

Thaxu:
For the step counting....that is my question to the forum. How can i impliment a code that counts steps.

For that, I reformulated the question so you hopefully could answer it.

Where in the code do you know you turn a single rotation?
Or more specific, where do you program a full rotation?

If you know that, can't you than simply also increase a variable every time you do so? And after that, use that same variable to see if you made enough rotations?

Thaxu:
Do i need to put somekind of "Serial.printin" for the motor step counting?

Huh, what!? Don't be a code monkey! How would sending something to serial fix that? That would be like sending a letter to your uncle when you try to brush your teeth.... That's not magically make that happen, does it?

Thaxu:
I have made my code from many other codes. I have mixed it to the result i have posted here.

Don't just mix (and be that code monkey), go over it LINE by LINE and understand why you need ALL of them.

Septillion...if you are just being an elitist prick you can just shut it. Just simple "Try X or Try Y" would do the trick. I linked my code for the reason that people can point what i need to add and where, not because you can call me code monkey.

i a using the base structure of this code found in this thread.

Thaxu:
Septillion…if you are just being an elitist prick you can just shut it. Just simple “Try X or Try Y” would do the trick. I linked my code for the reason that people can point what i need to add and where, not because you can call me code monkey.

i a using the base structure of this code found in this thread.

http://forum.arduino.cc/index.php?topic=85335.0

Quick note from a fellow noobie… You are not going to get anywhere with that type of attitude. If you are fortunate enough to get someone to take the time to look at your post then they likely have an idea of the solution but want to help you help YOU get to that solution. Take a chill and go back and really read what he was saying… you are really close.

Iim glad someone checks it up, but if im being made fun of just by asking, thats not ok. I know im close, iv been working with this for 30h by now and im out of ideas. So politeness from all participants is key.

Make it easier for others to help you (remember they are doing so for free). There’s a very cleverly-titled post at the top of every forum page: Read this before posting a programming question .... As its title implies, you should have, you know, read it before you posted your programming question. Please do so now. Pay particular attention to Item #6. It describes how to properly post your code using code tags. Your code it small enough to do use this technique. That way, people don’t have to download it. Before doing this, hit “ctrl-t” in the Arduino IDE. This will auto-format the code for you. There’s nothing worse than looking at ugly code with poor indentation.

Thaxu:
Iim glad someone checks it up, but if im being made fun of just by asking, thats not ok. I know im close, iv been working with this for 30h by now and im out of ideas. So politeness from all participants is key.

No you are not.

It is a forum for help to understand programming. If you don't even have a clue what your code does just drop it and get a different hobby!