EasyManuals Logo

Arduino uno User Manual

Arduino uno
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #88 background imageLoading...
Page #88 background image
If youve copied the files but made any syntactical errors, youll also be notified
now. If you have to correct some errors, make sure you change your original
source code files. After youve fixed the errors, copy the files to the
libraries
folder again, and dont forget to restart the IDE.
Turning a static string into Morse code is nice, but wouldnt it be great if our
program could work for arbitrary strings? So, lets add a more sophisticated
example. This time, well write code that reads messages from the serial port
and feeds them into a
Telegraph
instance.
Create a new sketch named
MorseCodeGenerator
and enter the following code:
TelegraphLibrary/examples/MorseCodeGenerator/MorseCodeGenerator.ino
#include "telegraph.h"
const unsigned int OUTPUT_PIN = 13;
const unsigned int DIT_LENGTH = 200;
const unsigned int MAX_MESSAGE_LEN = 128;
const unsigned int BAUD_RATE = 9600;
const char NEWLINE = '\n';
char message_text[MAX_MESSAGE_LEN];
int index = 0;
Telegraph telegraph(OUTPUT_PIN, DIT_LENGTH);
void setup() {
Serial.begin(BAUD_RATE);
}
void loop() {
if (Serial.available() > 0) {
int current_char = Serial.read();
if (current_char == NEWLINE || index == MAX_MESSAGE_LEN - 1) {
message_text[index] = 0;
index = 0;
telegraph.send_message(message_text);
} else {
message_text[index++] = current_char;
}
}
}
Again, we include the header file of the
Telegraph
class, and as usual we define
some constants:
OUTPUT_PIN
defines the pin our LED is connected to, and
DIT_LENGTH
contains the length of a dit measured in milliseconds.
NEWLINE
is
set to the ASCII code of the newline character. We need it to determine the
report erratum discuss
Installing and Using the Telegraph Class 69
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino uno and is the answer not in the manual?

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals