Arduino Workshop - Chapter Two - Using Serial Monitor

preview_player
Показать описание

In this section, we'll be looking at using the serial port on the Arduino to communicate with a computer via USB.

Рекомендации по теме
Комментарии
Автор

why you don't use the auto format option after copying the sketch ?

batticha
Автор

i have been watching your workshop it is great i am having a problem when i try to manage my library or upload to my library it keep saying please can you help

martinspence
Автор

my serial monitor says "not connected. select a board to connect automatically" how can i fix this??

catiru
Автор

Can't u use ctrl+t to do the indentation?

babyyoda
Автор

Ah Crap, I read that title as using Two Serial ports, since At Mega has two ports. can I shunt the data of one Serial.read() to print that out in the second Serial port and view that in the serial monitor?
It be helpful to he able to see the incoming data, while using it...

daveklebt
Автор

Can you tell me how can I erase the old data from my Arduino Uno board to upload a new one

onkarkumar
Автор

sorry for my English
does the the serial monitor function only when arduino is connected with the PC?

ildisonorevolesannita
Автор

For some reason my serial monitor doesn't make a new line :( do you know the reason?

hissenguinho
Автор

int ledPin = 3;
int buttonPin = 2;
int potPin = A0;

void setup() {
// setup pin modes
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(potPin, INPUT);

// initialise serial port with baud rate of 9600
Serial.begin(9600);
}

void loop() {
// read the state of buttonPin and store it as buttonState (0 or 1)
int buttonState = digitalRead(buttonPin);

// read the value of the pot, divide it by 4, and store it as potValue
int potValue = analogRead(potPin);
int filteredPotValue = potValue / 4;

// turn led on with the value of potValue
analogWrite(ledPin, filteredPotValue);

// print the value of the button
Serial.print("Button: ");
Serial.print(buttonState);
Serial.print(" ");

// print the value of the pot
Serial.print("Pot: ");
Serial.print(potValue);
Serial.print(" ");

// print the value of the pot / 4 with a line return at the end
Serial.print("Pot/4: ");

}

jettanat