Skip to content
Snippets Groups Projects
Commit 26ed5d2f authored by Dorota Orlof's avatar Dorota Orlof
Browse files

adding code files

parents
No related branches found
No related tags found
No related merge requests found
#include <SoftwareSerial.h>
SoftwareSerial doraSerial(1, 4);
void setup() {
doraSerial.begin(9600);
}
void loop() {
doraSerial.write("Hello Barca");
doraSerial.write("\n");
delay(10);
}
#include <SoftwareSerial.h>
SoftwareSerial doraSerial(8, 6);
char val;
int ledPin = 7;
void setup() {
pinMode(ledPin, OUTPUT);
doraSerial.begin(9600);
}
void loop() {
if (doraSerial.available())
{
int bytesSent = doraSerial.write("hello"); //send the string "hello" and return the length of the string.
}
delay(10);
}
#include <SoftwareSerial.h>
SoftwareSerial doraSerial(8, 4);
char val; // Data received from the serial port
int ledPin = 7; // Set the pin to digital I/O 13
boolean ledState = LOW; //to toggle our LED
void setup()
{
pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
//initialize serial communications at a 9600 baud rate
doraSerial.begin(9600);
establishContact(); // send a byte to establish contact until receiver responds
}
void loop()
{
if (doraSerial.available() > 0) { // If data is available to read,
val = doraSerial.read(); // read it and store it in val
if(val == '1') //if we get a 1
{
ledState = !ledState; //flip the ledState
digitalWrite(ledPin, ledState);
}
delay(100);
}
else {
doraSerial.println("Hello, Barca!"); //send back a hello world
delay(50);
}
}
void establishContact() {
while (doraSerial.available() <= 0) {
doraSerial.println("A"); // send a capital A
delay(300);
}
}
#include <SoftwareSerial.h>
SoftwareSerial doraSerial(8, 4);
char val; // Data received from the serial port
int ledPin = 7;
boolean ledState = LOW;
void setup()
{
pinMode(ledPin, OUTPUT);
doraSerial.begin(9600);
establishContact(); // send a byte to establish contact until receiver responds
}
void loop()
{
if (doraSerial.available() > 0) { // If data is available to read,
val = doraSerial.read(); // read it and store it in val
if(val == '1') //if we get a 1
{
ledState = !ledState; //flip the ledState
digitalWrite(ledPin, ledState);
}
delay(100);
}
else {
doraSerial.println("Hello, Barca!"); //send back a hello world
delay(50);
}
}
void establishContact() {
while (doraSerial.available() <= 0) {
doraSerial.println("A"); // send a capital A
delay(300);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment