Robots Atlas>ROBOTS ATLAS

Arduino for Beginners · Sketch Programming Fundamentals

Variables, data types (int, float, bool, char) and operators

Sketch Programming Fundamentals

Introduction

Variables are named memory cells where a sketch stores numbers, characters and flags. This lesson shows how to declare and initialize variables, how local and global scope works, and the const keyword and #define. We dissect the AVR types and their EXACT sizes on the ATmega328P (int = 2 bytes, long = 4 bytes, float = 4 bytes, double = float, char/byte/bool = 1 byte) plus every operator group. Finally the pitfalls: int overflow, integer division 5/2 = 2, and confusing = with ==.