0% found this document useful (0 votes)
4 views2 pages

C++ Coding for Arduino Board

Uploaded by

sakshisarita61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

C++ Coding for Arduino Board

Uploaded by

sakshisarita61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Coding for Arduino Board

1. Data Types
Data types tell the Arduino what kind of data you want to store or use.

Common Data Types:

 • int - Whole numbers (e.g., 10)


 • float - Decimal numbers (e.g., 3.14)
 • char - Single character (e.g., 'A')
 • bool - True or False (e.g., true)
 • String - Text (e.g., "Hello")
 • long - Large integers
 • byte - Small numbers from 0 to 255

Example:

int age = 25;


float temperature = 36.5;
char grade = 'A';
bool isLightOn = false;
String name = "Agampreet";

2. void setup()
• This function runs only one time when the Arduino board starts or resets.

• It is used to set up things like pin modes and serial communication.

Example:

void setup() {
pinMode(13, OUTPUT); // Set pin 13 as output
Serial.begin(9600); // Start serial monitor
}

3. void loop()
• This function runs again and again in a continuous loop.
• Main program code goes here, which needs to be repeated.

Example:

void loop() {
digitalWrite(13, HIGH); // Turn on LED
delay(1000); // Wait for 1 second
digitalWrite(13, LOW); // Turn off LED
delay(1000); // Wait for 1 second
}

4. Summary Table
Term Use

int Whole numbers like 1, 2, 3

float Decimal numbers like 3.14

char Single letter like 'A'

bool True or False values

String Text like "Hello"

void setup() Runs once at start, used to set up pins and


settings

void loop() Runs forever in a loop, used for repeating


tasks

You might also like