Академический Документы
Профессиональный Документы
Культура Документы
Laboratory Exercise #5
Interfacing Other STEM Sensors and Actuators
to the ACEDuino328
Objectives:
At the end of the exercise, the students should be able to:
Materials:
1 – ACEDuino board
1 – Personal Computer
1 – A to B scanner/printer cable
1 – POWERON STEM 1.0 KIT
Set of wires
Prototyping board
Pin connectors
Procedures:
NOTE: Please observe safety precautions and proper handling while conducting the laboratory experiment.
This experiment is to be performed under an instructor’s supervision.
1. Get the following components below from the POWERON Stem 1. 0 kit.
1 2# Slab 1 4# Slab
4 Bearing 1 Bottle
2. Next, assembly the components according to the given the steps below.
1 2
3 4
5 6
7 8
9 10
11 12
3. Now, open the Arduino IDE software and type the following code below.
#include <avr/io.h>
void setup () {
pinMode (1,OUTPUT);
pinMode (13,OUTPUT);
}
void loop () {
digitalWrite (1,HIGH); //turn the electromagnet ON
digitalWrite (13,HIGH);
delay (5000); //wait for five seconds
digitalWrite (1,LOW); //turn the electromagnet OFF
digitalWrite (1,LOW);
delay (1000);
}
4. After encoding the program above, connect the gray wire of the electromagnet to the Pin 1 of
ACEDuino328 and the white wire to the GND.
5. Upload the program to the ACEDuino328 board and see what happens. Does the on-board LED lit? What
does it implies? Write your observation below:
Observation:
6. Now, connect the gray wire of the electromagnet to the on-board 5V source. Repeatedly, connect and
disconnect this wire from the 5V-source of the ACEDuino328. What have you notice? Write your
observation below:
Observation:
1. Get the light sensor shown below from the PowerON Stem 1.0 kit.
2. Next, connect the gray wire of the above - mentioned sensor in series with a 1- kilo ohm resistor while the
white wire of it is to be connected to the GND of the board. Note: The other end of the resistor must be
connected to the 3V3 of the ACEDuino328 board.
3. Now, connect the point of connection between the sensor and the resistor to the ANALOG IN 1 of the
ACEDuino328 board.
4. Copy the code below and see what happens when the sensor is exposed to light.
#include <avr/io.h>
int val = 0;
void setup () {
pinMode (1,OUTPUT);
pinMode (13,OUTPUT);
}
void loop () {
val = analogRead (1);
if (val > 511)
{
digitalWrite (13,LOW);
delay (1000);
}
else
{
digitalWrite (13,HIGH);
delay (1000);
}
}
EXERCISE
1. Since the light sensor is measured using an analog to digital converter, use the same circuit to control the
speed of the motor. The speed of the motor is dictated by the intensity of the light being measured by the
light sensor.
1. Get the following components from the POWERON Stem 1.0 kit,
2. Next, assembly the components according to the given the figure below.
3. Again, connect the gray wire of the sensor in series with a 1-kilo ohm resistor. The other end of the
resistor must be connected to the 3V3 of the ACEDuino328 board. Connect the white wire of the light
sensor to the GND of the board.
4. Connect the point of connection between the sensor and the resistor to Pin 2 of the ACEDuino328 board.
5. Copy the code below and see what happens to the on-board LED at Pin 13 when you rotate the 5:1 gear
case slowly. Notice that either the turning ON/OFF of the LED indicates an event, thus this becomes a
counter.
#include <avr/io.h>
int val = 0;
void setup () {
pinMode (2,INPUT);
pinMode (13,OUTPUT);
}
void loop () {
val = digitalRead (2);
if (val == 0)
{
digitalWrite (13,LOW);
delay (1000);
}
else
{
digitalWrite (13,HIGH);
delay (1000);
}
}
EXERCISE
1. Extend the above exercise so that you can actually count the number of rotations of a motor in various
speeds.
Observation: