Professional Documents
Culture Documents
In this project when you press a key, its displayed the value in your serial montior. Heres what you
should see in your Arduino IDE serial monitor when you start pressing the keypad keys.
Conclusion
Now you can create an interface for your Arduino using a keypad. You could also add an LCD to this
project.
Because these keypads consume 7 or 8 io pins, it may be better in some projects to use them in
conjunction with an IIC port expander. You can find some modules on aliexpress (and probably ebay too)
that have 8 digital ports, based on the 8574 chip, for under $5. On aliexpress search for things like IIC
8574 I/O and you can find modules with header pins ready to go. Using IIC you only use up 2 analog
pins on your arduino, plus you can still daisy chain other IIC devices like a 1602 LCD if desired.
I2C
http://playground.arduino.cc/Main/WireLibraryDetailedReference
http://tronixstuff.com/2010/05/20/getting-started-with-arduino-chapter-seven/
The I2C bus (also known as two wire interface) is the name of a type of interface between devices
(integrated circuits) that allows them to communicate, control and share data with each other. (It was
invented by Philips in the late 1970s.
SDA (serial data) and the other SCL (serial clock).
Maxim DS1307 Serial I2C real-time clock.
ine minte ceasul chiar nealimentat i genereaz unde dreptunhjiulare
First of all, we need to know the I2C address for our DS1307. It is 068 in hexadecimal. Addresses are
unique to the device type, not each individual device of the same type.
/*
Example 7.3
reading and writing to the Maxim DS1307 real time clock IC
tronixstuff.com/tutorials
based on code by Maurice Ribble
17-4-2008 - http://www.glacialwanderer.com/hobbyrobotics
*/
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 Este adresa fix dat de fabric a circuitului
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f); // Need to change this if 12
hour am/pm
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);
// Change these values to what you want to set your clock to.
// You probably only want to set your clock once and then remove
// the setDateDs1307 call.
second = 0;
minute = 47;
hour = 0;
dayOfWeek = 3;
dayOfMonth = 31;
month = 3;
year = 12;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Client
Trimite un mesaj i ateapt rspunsul
// client.pde
//
// Simple example of how to use VirtualWire to send and receive messages
// with a DR3100 module.
// Send a message to another arduino running the 'server' example, which
// should send a reply, which we will check
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: client.pde,v 1.1 2008/04/20 09:24:17 mikem Exp $
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
const char *msg = "hello";
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
Serial.println("Sent");
digitalWrite(13, false);
// Wait at most 200ms for a reply
if (vw_wait_rx_max(200))
{
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], HEX);
Serial.print(" ");
}
Serial.println("");
}
}
else
Serial.println("Timout");
}
Server
Ateapt uhn mesaj i rspunde
// server.pde
//
// Simple example of how to use VirtualWire to send and receive messages
// with a DR3100 module.
// Wait for a message from another arduino running the 'client' example,
// and send a reply.
// You can use this as the basis of a remote control/remote sensing system
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: server.pde,v 1.1 2008/04/20 09:24:17 mikem Exp $
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
const char *msg = "hello";
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
// Wait for a message
vw_wait_rx();
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
const char *msg = "goodbye";
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], HEX);
Serial.print(" ");
}
Serial.println("");
// Send a reply
vw_send((uint8_t *)msg, strlen(msg));
digitalWrite(13, false);
}
}
LCD monocrom
Four-bit parallel interface
This is the cheapest method of interface, and our first example for this article. Your LCD will need a
certain type of controller IC called a Hitachi HD44780 or compatible such as the KS0066. From a
hardware perspective, there are sixteen pins on the LCD. These are usually in one row:
GND
5V (careful! Some LCDs use 3.3 volts adjust according to LCD data sheet from supplier)
Contrast
RS
RW
Enable
DB0 (pins DB0~DB7 are the data lines)
DB1
DB2
DB3
DB4
DB5
DB6
DB7
backlight + (unused on non-backlit LCDs) again, check your LCD data sheet as backlight voltages can
vary.
backlight GND (unused on non-backlit LCDs)
GLCD
http://tronixstuff.com/2011/01/08/tutorial-arduino-and-monochrome-lcds/
ILI9325 LCD TFT
IrDA
http://tronixstuff.com/2011/03/30/tutorial-arduino-and-infra-red-control/
ILI 9325 LCD TFT 240x320
http://tronixstuff.com/2013/04/26/tutorial-arduino-and-ili9325-colour-tft-lcd-modules/
ADC
ADC 1110 16 bii
#include "Wire.h"
#define ads1110 0x48
float voltage, data;
byte highbyte, lowbyte, configRegister;
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
Wire.requestFrom(ads1110, 3);
while(Wire.available()) // ensure all the data comes in
{
highbyte = Wire.read(); // high byte * B11111111
lowbyte = Wire.read(); // low byte
configRegister = Wire.read();
}
SPI
Poate comunica n ambele sensuri. I2C nu poate.
MOSI Master-out, Slave-in. This line carries data from our Arduino to the SPI-controlled device(s);
MISO Master-in, Slave out. This line carries data from the SPI-controlled device(s) back to the
Arduino;
SS Slave-select. This line tells the device on the bus we wish to communicate with it. Each SPI device
needs a unique SS line back to the Arduino;
SCK Serial clock.
Within these tutorials we consider the Arduino board to be the master and the SPI devices to be slaves. On
our Arduino Duemilanove/Uno and compatible boards the pins used are:
SS digital 10. You can use other digital pins, but 10 is generally the default as it is next to the other SPI
pins;
MOSI digital 11;
MISO digital 12;
SCK digital 13;
#include "SPI.h"
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setBitOrder(LSBFIRST);
SPI.transfer(value); emite sau primete
Pentru a citi se selecteaz registrul i se scrie 0
// send the device the register you want to read:
SPI.transfer(dataToSend);
// send a value of 0 to read the first byte returned:
result = SPI.transfer(0x00); -- se poate repeta dac serverul mai are de trimis un byte
Ultrasunete
http://tronixstuff.com/2011/11/28/tutorial-parallax-ping-ultrasonic-sensor/
The Ping))) only measures a distance when requested to do this we send a very short HIGH pulse of
five microseconds to the signal pin.
// Example 45.1 - tronixstuff.com - CC by-sa-nc
// Connect Ping))) signal pin to Arduino digital 8
int signal=8;
int distance;
unsigned long pulseduration=0;
void setup()
{
pinMode(signal, OUTPUT);
Serial.begin(9600);
}
void measureDistance()
{
// set pin as output so we can send a pulse
pinMode(signal, OUTPUT);
// set output to LOW
digitalWrite(signal, LOW);
delayMicroseconds(5);
Ethernet
! ARDUINO C Programming si hard Bayle.pdf
Adresa MAC o gsesc pe plac
Adresa IP trebuie s fie unic n reea
Appletul de pe calc
We need the library hypermedia. We can find it at http://ubaa.net/shared/
processing/udp.
Autorul prefer protocolul UDP
Pentru TCP http://arduino.cc/en/Reference/Ethernet.
Bluetooth
2400-2480 MHz
Permite crearea de reele cu securitate
Modelul referit https://www.sparkfun.com/products/10559 cost 59$
Wi-FI
Wi-Fi isa set of communication protocols wireless driven by standards of IEEE
802.11. These standards describe characteristics of Wireless Local Area Networks
(WLANs).
Mai multe tipuri:
Infrastructure mode: se comunic printr-un nod, securitate
Ad-hoc, fiecare cu fiecare
Dei mai bun, mai ieftin ca bluet
Internet, cuplare la twitter
! ARDUINO C Programming si hard Bayle.pdf
Internet, interogare Google
This example shows you how to make a HTTP request using an Ethernet shield. It returns a Google
search for the term "Arduino". The results of this search are viewable as HTML through your Arduino's
serial window.
/*
Web client