Comment on: C Plus Equality (C+=), a feminist programming language
6 20 Jun 2015 00:20 u/chrzan in v/programmingComment on: C Plus Equality (C+=), a feminist programming language
I lost it at "OOP (objectification-oriented programming)." Kek.
Comment on: My Robot C Program Which Opens and Closes Blinds Automatically Depending on Light Intensity
Using programming to affect physical objects in real life is so much fun! Even a simple project can bring a lot of satisfaction and end up useful.
Here's some comments/questions about your code:
Why don't you stop the motors inside the open/closeBlinds() functions? A function should be a complete idea that does what its name implies. What you currently have could be dangerous - if you forget to add a motor [motorB] = 0 statement after calling the function, the motor will just keep running, wasting some power in the best case scenario, damaging itself or other objects in the worst.
To overcome the problem that @taxation_is_slavery mentioned (the blinds opening and closing rapidly when the light intensity is right around 50, going slightly above and below regularly) you could set a higher threshold for when to close the blinds and a lower for when to open them. Somewhere in the range of 45-55 you should be comfortable with the blinds being either open or closed, so if you open them at 45, they won't close again until the light intensity changes quite a bit - it has to go all the way up to 55. They will then stay closed until, once again, the light intensity's change will be significant, down to 45.
Final comment: you don't need the else statements after checking the sensor value. The motor is already set to 0, so there's nothing that needs to be done if the threshold hasn't been passed.
Comment on: My Robot C Program Which Opens and Closes Blinds Automatically Depending on Light Intensity
Not OP, but I used it with Lego Mindstorms in a high school robotics course. Looks like it's also used on VEX and CORTEX.
From the Privilege Checker example: