Arduino Rapid Prototyping Coursework: ENG434s1 Project Solutions
VerifiedAdded on 2022/11/13
|9
|1078
|382
Practical Assignment
AI Summary
This document provides a comprehensive solution for an Arduino rapid prototyping coursework, focusing on three key projects. The first project involves controlling the brightness of an LED using two push buttons, incorporating a buzzer for feedback. The second project demonstrates sensor reading and data logging, utilizing an LM35 temperature sensor and an SD card for storing data. The third project implements a smart home monitoring system, which reads and displays data from a photocell sensor, an LM35 temperature sensor, and an analog sound sensor. The document includes Arduino sketches, hardware connections, and explanations for each project, offering a practical guide to electronic product design and rapid prototyping using Arduino.

Rapid Prototyping using Arduino
Student Name –
Student ID -
Student Name –
Student ID -
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Contents
Fading LED.............................................................................................................................................3
Sensor Reading and Data logging..........................................................................................................5
Smart Home...........................................................................................................................................7
Fading LED.............................................................................................................................................3
Sensor Reading and Data logging..........................................................................................................5
Smart Home...........................................................................................................................................7

Fading LED
In this case, an Arduino sketch is created to control LED brightness using 2 push buttons, B1
and B2. We are using B1 to increase the brightness and B2 to decrease the brightness. A
buzzer is also included to indicate when the maximum or minimum brightness is reached. We
require an Arduino (Uno), a breadboard, connecting wires, 2 push buttons and an LED.
We connect an LED on pin 11. Two push buttons with pull-down resistors are used. The
pushbutton connected to pin 10 increases the LED's brightness. The pushbutton connected to
pin 9 decreases the LED's brightness.
Hardware :
We have also connected a digital buzzer to pin 3.
Figure 1
Figure 2
In this case, an Arduino sketch is created to control LED brightness using 2 push buttons, B1
and B2. We are using B1 to increase the brightness and B2 to decrease the brightness. A
buzzer is also included to indicate when the maximum or minimum brightness is reached. We
require an Arduino (Uno), a breadboard, connecting wires, 2 push buttons and an LED.
We connect an LED on pin 11. Two push buttons with pull-down resistors are used. The
pushbutton connected to pin 10 increases the LED's brightness. The pushbutton connected to
pin 9 decreases the LED's brightness.
Hardware :
We have also connected a digital buzzer to pin 3.
Figure 1
Figure 2
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

Arduino Sketch :
Const int bu = 10;
Const int bd = 9;
Const int ledp = 11;
Const int maxb = 12; // steps between extreme ends of brightness
int buzzerPin = 3; // Connect Buzzer to the Digital Pin3
Int b = maxb;
Int i = 1;
Void setup ( )
{
pinMode ( ledp , OUTPUT ) ;
pinMode ( bu , INPUT ) ;
pinMode ( bd , INPUT) ;
pinMode ( buzzerPin , OUTPUT ) ;
Serial.begin ( 9600 ) ;
}
Void loop ( )
{
if ( digitalRead ( bu ) = = HIGH && b < maxb )
{
b = b + i ;
If ( b == maxb )
{
digitalWrite ( buzzerPin , HIGH ) ;
delay ( 10 ) ;
}
}
If ( digitalRead ( bd ) == HIGH && b > 0 )
{
b = b – i ;
Const int bu = 10;
Const int bd = 9;
Const int ledp = 11;
Const int maxb = 12; // steps between extreme ends of brightness
int buzzerPin = 3; // Connect Buzzer to the Digital Pin3
Int b = maxb;
Int i = 1;
Void setup ( )
{
pinMode ( ledp , OUTPUT ) ;
pinMode ( bu , INPUT ) ;
pinMode ( bd , INPUT) ;
pinMode ( buzzerPin , OUTPUT ) ;
Serial.begin ( 9600 ) ;
}
Void loop ( )
{
if ( digitalRead ( bu ) = = HIGH && b < maxb )
{
b = b + i ;
If ( b == maxb )
{
digitalWrite ( buzzerPin , HIGH ) ;
delay ( 10 ) ;
}
}
If ( digitalRead ( bd ) == HIGH && b > 0 )
{
b = b – i ;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

if ( b == 0 )
{
digitalWrite ( buzzerPin , LOW ) ;
delay ( 10 ) ;
}
}
Delay ( 120 ) ;
analogWrite ( ledp , map ( b , 0 , maxb , 0 , 255 ) ) ;
}
Sensor Reading and Data logging
In this case, an Arduino sketch is created to read a sensor and then the data is written on an
SD card.
Figure 3
LM35 Linear Temperature Sensor has been used here.
Connection of SD Card to SPI bus: MOSI to pin 11, MISO to pin 12, CLK to pin 13 and CS
to pin 4 ( MKRZero SD – SDCARD_SS_PIN)
{
digitalWrite ( buzzerPin , LOW ) ;
delay ( 10 ) ;
}
}
Delay ( 120 ) ;
analogWrite ( ledp , map ( b , 0 , maxb , 0 , 255 ) ) ;
}
Sensor Reading and Data logging
In this case, an Arduino sketch is created to read a sensor and then the data is written on an
SD card.
Figure 3
LM35 Linear Temperature Sensor has been used here.
Connection of SD Card to SPI bus: MOSI to pin 11, MISO to pin 12, CLK to pin 13 and CS
to pin 4 ( MKRZero SD – SDCARD_SS_PIN)

Arduino Sketch :
#include <SPI.h>
#include <SD.h>
File myFile1;
void setup()
{
Serial.begin ( 9600 ) ; //Setting the Baud Rate equal to 9600 bps
}
void loop ( )
{
int ans;
int dat1;
ans = analogRead ( 0 ) ; // Connection of LM35 to the pin Analog 0
dat1 = (500 * ans) /1024;
While ( !Serial )
{
;
}
Serial.print ( “Initialising” ) ;
if ( !SD.begin ( 4 ) )
{
Serial.println ( " Failed Initialisation " ) ;
while ( 1 ) ;
}
Serial.println ( " Initialized " ) ;
myFile1 = SD.open ( " test1.txt " , FILE_WRITE ) ;
if (myFile1)
{
myFile1.print ( “ Temp : ” ) ;
myFile1.print ( dat1 ) ;
myFile1.print ( “ degree C ” ) ;
myFile1.close ( ) ;
Serial.println ( " Finished " ) ;
}
else
{
Serial.println ( " Error " ) ;
}
#include <SPI.h>
#include <SD.h>
File myFile1;
void setup()
{
Serial.begin ( 9600 ) ; //Setting the Baud Rate equal to 9600 bps
}
void loop ( )
{
int ans;
int dat1;
ans = analogRead ( 0 ) ; // Connection of LM35 to the pin Analog 0
dat1 = (500 * ans) /1024;
While ( !Serial )
{
;
}
Serial.print ( “Initialising” ) ;
if ( !SD.begin ( 4 ) )
{
Serial.println ( " Failed Initialisation " ) ;
while ( 1 ) ;
}
Serial.println ( " Initialized " ) ;
myFile1 = SD.open ( " test1.txt " , FILE_WRITE ) ;
if (myFile1)
{
myFile1.print ( “ Temp : ” ) ;
myFile1.print ( dat1 ) ;
myFile1.print ( “ degree C ” ) ;
myFile1.close ( ) ;
Serial.println ( " Finished " ) ;
}
else
{
Serial.println ( " Error " ) ;
}
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

Serial.print ( " Temp : " ) ; //Show the temperature on the Serial monitor
Serial.print ( dat1 ) ;
Serial.println ( " degree C " ) ;
Delay ( 250 ) ;
}
Smart Home
In this case, an Arduino sketch has been created for a monitoring system which can monitor,
record and display sensor data for 3 different types. The sensors used are : Photocell Sensor
( Pin A0), LM35 Temperature Sensor ( Pin A1 ) and Analog Sound Sensor ( Pin A2 ). We
have connected push button to pin 13.
Photocell Sensor
Figure 4
Arduino Sketch :
# include < LiquidCrystal.h >
LiquidCrystal lcd (7, 8, 9, 10, 11, 12) ; // Pins for Interfacing
int photosen = A0 ;
int tempsen = A1 ;
int soundsen = A2 ;
int val = 0 ;
const int sp = 13 ;
static int h = 0 ;
Serial.print ( dat1 ) ;
Serial.println ( " degree C " ) ;
Delay ( 250 ) ;
}
Smart Home
In this case, an Arduino sketch has been created for a monitoring system which can monitor,
record and display sensor data for 3 different types. The sensors used are : Photocell Sensor
( Pin A0), LM35 Temperature Sensor ( Pin A1 ) and Analog Sound Sensor ( Pin A2 ). We
have connected push button to pin 13.
Photocell Sensor
Figure 4
Arduino Sketch :
# include < LiquidCrystal.h >
LiquidCrystal lcd (7, 8, 9, 10, 11, 12) ; // Pins for Interfacing
int photosen = A0 ;
int tempsen = A1 ;
int soundsen = A2 ;
int val = 0 ;
const int sp = 13 ;
static int h = 0 ;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

int ss = 0 ;
int prevSs = 0;
void setup ( )
{
lcd.begin (16, 2) ; // Set rows and columns
lcd.clear ( ) ;
pinMode ( photosen , INPUT ) ;
pinMode ( tempsen, INPUT ) ;
pinMode ( soundsen , INPUT ) ;
pinMode ( sp , INPUT ) ;
Serial.begin ( 9600 ) ; // baud rate 9600
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ;
lcd.print ( " Press the button " ) ;
lcd.setCursor ( 0 , 1 ) ;
lcd.print ( " for results " ) ;
}
void loop ( )
{
ss = digitalRead ( sp ) ;
Serial.print ( " ss : " ) ;
Serial.println ( ss ) ;
if ( ss ! = prevSs )
{
if ( ss == HIGH )
{
h = h + 1 ;
delay ( 10 ) ;
}
}
if ( h % 3 = = 1 )
{
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ; // Sets the cursor to column 0 and row 0
lcd.print ( " SensorVal1 : " ) ;
lcd.print (analogRead ( photosen ) ) ;
}
else
if ( h % 3 = = 2 )
{
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ;
int prevSs = 0;
void setup ( )
{
lcd.begin (16, 2) ; // Set rows and columns
lcd.clear ( ) ;
pinMode ( photosen , INPUT ) ;
pinMode ( tempsen, INPUT ) ;
pinMode ( soundsen , INPUT ) ;
pinMode ( sp , INPUT ) ;
Serial.begin ( 9600 ) ; // baud rate 9600
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ;
lcd.print ( " Press the button " ) ;
lcd.setCursor ( 0 , 1 ) ;
lcd.print ( " for results " ) ;
}
void loop ( )
{
ss = digitalRead ( sp ) ;
Serial.print ( " ss : " ) ;
Serial.println ( ss ) ;
if ( ss ! = prevSs )
{
if ( ss == HIGH )
{
h = h + 1 ;
delay ( 10 ) ;
}
}
if ( h % 3 = = 1 )
{
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ; // Sets the cursor to column 0 and row 0
lcd.print ( " SensorVal1 : " ) ;
lcd.print (analogRead ( photosen ) ) ;
}
else
if ( h % 3 = = 2 )
{
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ;

lcd.print ( " SensorVal2: " ) ;
lcd.print ( analogRead ( tempsen ) ) ;
delay ( 500 ) ;
}
else
if ( h % 3 = = 3 )
{
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ;
lcd.print ( " SensorVal3 : " ) ;
lcd.print ( analogRead ( soundsen ) ) ;
delay ( 100 ) ;
}
delay ( 1000 ) ;
}
lcd.print ( analogRead ( tempsen ) ) ;
delay ( 500 ) ;
}
else
if ( h % 3 = = 3 )
{
lcd.clear ( ) ;
lcd.setCursor ( 0 , 0 ) ;
lcd.print ( " SensorVal3 : " ) ;
lcd.print ( analogRead ( soundsen ) ) ;
delay ( 100 ) ;
}
delay ( 1000 ) ;
}
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 9
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2026 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.
