0% found this document useful (0 votes)
23 views

Arduino Prog

This document discusses various Arduino functions related to input/output pin operations, serial communication, string handling, timing functions, and analog/digital reading and writing. Key functions covered include pinMode, digitalWrite, delay, Serial.begin, print, println, analogRead, digitalRead, and analogWrite.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Arduino Prog

This document discusses various Arduino functions related to input/output pin operations, serial communication, string handling, timing functions, and analog/digital reading and writing. Key functions covered include pinMode, digitalWrite, delay, Serial.begin, print, println, analogRead, digitalRead, and analogWrite.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

arduinoProg>

pinMode(13,OUTPUT) :: Pin 13 use as output port.:: put this in setup() section.

digitalWrite(13,HIGH) :: whatever connected in pin 13 put it in HIGH state. eg: LED


on. :: put this in loop() section.

delay(1000) :: 1000 milisec means 1 sec delay.:: loop() section.

https://www.youtube.com/watch?v=9uHZB7-T_XA&list=PLGs0VKk2DiYw-L-RibttcvK-
WBZm8WLEP&index=2

How current work? how semiconductor use to flow current?

variable put in first part of the program before setup().

int redLED=8; int / float/ String

millis()
digitalRead(pin_number) >> buttonState ---> int

INPUT_PULLUP

Serial.available() :: no of bytes are available in the serial port for reading.

Serial.read() :: returns the first bytes of serial data available for reading if
not return -1.

First check if data is available for reading in the received buffer if yes then
read it using .read() function.

if(Serial_port_number) :: T/F if the serial port are ready top communicate?

Serial.availableForWrite() :: number of bytes available for write in the serial


port buffer without blocking the write operation.

Serial.begin(baud_rate) :: configure the serial port's baud rate to communicate.

Serial.end() :: disable the serial port.

Arduino Serial find and findUntil Function reads the received buffer and test for
specified string or word present or not.

Serial.find(target_char, timeLength4Look) :: returns T/F, reads data from the


serial buffer until the target is found or time out received.

Example: boolean b= Serial.find("aa",5000); // 5 secs wait time

Serial.findUntil(target_char, terminated_Char) :: return Boolean until the target


not found? Times out apply ---> False. Or Terminating Character has reached.

If specified string is present in the buffer than the function return the true,
otherwise return false.
By default the findUntil function wait for terminating character before it return
false.
The Serial.findUntil() function wait for one second or timeout time, but findUntil
function return false immediately as soon as it receive the terminating character.
Example: isOKFound = Serial.findUntil("OK", "x"); // terminating character is 'x'

You can consider the terminating character as command end symbol, like in c
language compiler look for “;” for end of statement.

Serial.flush() :: clear buffer

Serial.parseInt() / serial.parseFloat() :: Parse into Integer or Float from buffer


reading.

This function is use to see whether any integer or floating point input is
available in the BUFFER. "I ate 314 tomatos" input is ready in the buffer then
Serial.parseInt() --> return 314, strip off --> "I ate"
buffer remain with --> " tomatoes". Same goes to .parseFloat() function.

print(val,format) :: format-->> BIN, OCT, DEC, HEX :: without newline.

println(val, format) :: '\r' and '\n'

Serial.wtrite() :: val--> byte of data send.


Serial.write() :: string --> send series of byte of data as string.
Serial.write() :: buffer, length --> buffer:array and length : array size. -->
series of bytes of data.

Serial.readBytesUntil(buffer, length, terminatorChar) :: reads characters from the


serial; port into a buffer.

Serial.readBytes(buffer, length) :: reads characters from the serial; port into a


buffer.

Serial.readString() :: reads characters fromthe serial buffer into a string.

Serial.readStringUntil(terminator)

strlen(str) --> get the length of the string except terminator.

sizeof(str) --> get the length with terminator.

strcpy(str1, str2) --> copy one from another.

strcat(str1, "rony") --> append to the end of the string.

delay(millisecs)
delayMicroseconds(millisecs)
millis() :: start of the arduino board
micros() ::

analogRead(pin) :: 0 to 1023 values


digitalRead(pin) :: 0 or 1 read.

digitalWrite(pin,INPUT/OUTPUT)
analogWrite(pin, value) :: 0 to 255 --> value

random()
randomSeed(seed)

You might also like