V: Programmable Electronics
I.Demo
Before this class, I learnt a little about Arduino Programming by self-study. Today, we are going to design more complicated and delicate program. According to the course website, I made a Demo for my LED. It can progressively change its lightness according to the MIN & MAX. For my former program, I only need it to switch on or off automatically.
If you are a beginner and want to know more about Arduino Programming, WELCOME TO OUR COURSE WEBSITE!
II. Button
1.Pulldown-Resistor
Following Nathan’s instructions, I build a kind of complicated circuit with a button and a PULLDOWN RESISTOR. For this program, when it will detect that the state of the pushbutton. When the pushbutton is pressed, it will detect HIGH-5V and the ledPin will becaome HIGH-bright. Else, it will detect LOW and ledPin will change to LOW-dim.
2.INPUT-PULLUP
Because of my interest, I want to operate in an opposite situdation of the former circuit: when the button is pressed, the LED become dim; else, the LED keep bright. To do this, I need to let the circuit detect GND when the button is pressed, and the circuit should detect 5V when the button is not pressed. For this reason, I remove the wire which connects the 5V and button. I just set the PIN 2 as an INPUT_PULLUP in my program. As a result, it can always detect 5V. In additon to, I connect the pressbutton from PIN 2 to GND with a wire. So when I press the button, the circuit will detect GND instead of 5V. Fortunately, it works.
The APP of making a sketch for your circuit is here-FRITZING
III. Motor
This is my first time to use a motor in laboratory instead of for my model car. So my goal is just let it to change the rotating direction automatically. Instead of attach it from a particular PIN to GND, which I usually do, I attach it from a PIN to another PIN. The reason is that it’s the easiest way to change its rotating direction. For example, if I connect it from PIN 4 to PIN 3 and set PIN 4 as HIGH and PIN 3 as LOW, the current will flow from PIN 4 to PIN 3 and the motor will rotate in one direction. But if I later set the PIN 4 as LOW and PIN 3 as HIGH, the current will flow in opposite direction. So does the motor. So let’s see my project!
IV. Test for triggering
I want to use the combinition of photo transistor and infra red LED to function as a trigger. When the photo transistor detects enough infra red light, it will allow current to flow through to start the motor. I do a test with the bulb and it succeeds. But unfortunately, I fail when I replace the bulb with the motor.
Summary
In the class on Thursday and lab time on Friday, I successfully do a lot of thing with electronics. Some of them are done in my prototype and some of them are done on my protoboard. They are all pretty successful. I learn how to build a triggering circuit and figure out the relationship between different pin and wires. Also, I learn how to program my electronic circuit. Programming is the most important thing because we are in a AUTOMATIC era. Our world is full of AI and internet.
But I also meet some problems. For example, I still don’t figure out the way of starting up my car. Although I did experiment with the photo-transistor, the experiment shows that collecting the infra red emitting by the infra red LED is a really hard thing. And even though the experiment is successful to switch on a LED, I failed to start up a motor. I still need to solve the problem of lack of voltage. Because for two motors, you need to have high enough voltage to start them. Fighting next week!