You are on page 1of 2

ITMT 488

Flex. Manufacturing Engineering Tech


Lab Report 1
Department of Applied Engineering and Technology
College of Science and Technology
Morehead State University
Describe the purpose of the laboratory (at least 50 words):
The purpose of this laboratory exercise is to familiarize us with coding with
the Arduino board by means of serial communication. To do this we simply
hooked the Arduino board up to the computer, and programmed a simple
code in which the Arduino would read messages from the pc and count the
number of letter As and blink the LED light as many times as the number
of appearances of the letter.

1. What commands or functions did you learn for Arduino?


Basic programming language for the Arduino such as X>0, X==0, X!>0, and
also for and while loops. I also learned the basic concepts of which port to use,
such as using pin 13 for the LED light, as well as simplistic stuff such as
hooking up the Arduino, and connecting it to the computer via the port.
2. Paste in this report the programming code (do not attach files).

// Pin 13 has an LED connected on most Arduino boards.


// give it a name:
int led = 13;
int i=0;
char c;
String a;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
//Serial.print("*");
while(Serial.available())
{
c=Serial.read();
if (c=='a')
i++;

Serial.print(".");
}
if(i>0){
Serial.println(i);
for (int j=1;j<=i;j++)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
}
i=0;
delay(100);
}

You might also like