BUS4TN007-3 / tehtävä 2 (assignment 2)


This is the assignment two where the objective was to install a sensor that we loaned from university. There was 6-7 different sensors available from distance sensors to Parallax 27401 that is a infrared receiver and emitter that we had as our group assignment where this particular sensor recognized the dimmer lighting. The sensor then outputs values depending on the lighting on the surface of it’s receivers. Unfortunately I did not have the opportunity to take a picture of the installed sensor but I will post it on later time, If will ever get my hands on it. The sensors are easy to use in the beginning so you can try it yourself, with the same materials as I have. Look for more information about the sensor that my group used from the web pages below.



Like I said, that we had many other sensors as well. The below link basically has some of the sensors that we used in the lab. If I remember correctly we had other sensors as well.


So to the assignment itself that we had to work on. Unfortunately, because I did not buy my own sensors, I had to loan from my university because of these reasons and huge number of students that also loaned the sensors, my group had to work on the sensors that were available in the lab namely the switch or button if you will.
We also had few LED’s and jump wires and switch board. In the first picture as you can see, there is no need for codes for it to work. The switch takes power from the Arduino board and basically, it will distribute the electricity to the LED when someone pushes the button.


In the picture below a group member tries the switch button and as you can see, it works. Now again I have to emphasize that the wiring is not perfect.


Now in the previous example we did not really have any code to take input and output but in the next picture as you can see, the led is connected to Arduino through the pin directly where to control it, you would need some sort automated software like I had in the previous assignment or through user interaction like switch that is connected to Arduino. Arduino then recognizes, in what state the switch is by taking input from the switch as values, and determines what to do with the LED that is connected through the code.

Its nothing more than if, else if statement machine.
I think that no matter what the action is that we are supposed to achieved with this Arduino is all about booleans meaning if something is true then do something and if the value is not what we wanted, do something else. By the way I thought it would be good to post some switchboard logic that I learned from a classmate if someone still has some problems with it.


As you can see in the post above, I have drawn green lines. When you connect the jumper wires the logic works in a way that the red jumper wire in my case brings the electricity in meaning that from the third pin onward it will power the line and the switch and from the last leg of the switch the electricity will flow when the button is pushed through the whole line where the black jumper wire is connected. This way you can connect the GROUND to one line and connect many grounds on one line if needed.


I am going to post the code below but it is not without error’s but building prototype’s never was about creating fully working products right? here is the code without further delay

const int buttonPin = 12;
const int ledPin = 13;
int buttonState = 0;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}void loop(){

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
else {
digitalWrite(ledPin, LOW);

The source that I used to help me connect the Arduino is below


Last but not least heres the link to the person to my classmates blog with whom I worked with.

p.s. I will update the blog post later with more content.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s