Lightino Lessons Help Sheet

The Basics

  • Statements are grouped together by curly brackets { }, not by indentation (as in Python).
  • You can put newlines and spaces where you like, but your code will be easier to read if you indent it (like Python).
  • Everything between // and the end of the line, or between /* and */ is a comment.
  • All variables must be declared, defining their type. They have no meaning outside the smallest enclosing { }. Declarations must be the first things after {.
  • All statements (including declarations) must be terminated by a semicolon.
  • Lines beginning with # are definitions of constants or directives to include a file from somewhere else containing stuff you'll be needing.


int a, b, c; // Declare 3 integers

float x; // Declare a floating point variable (needn't be a whole number)

boolean love_marmite; // Takes the values true or false

char c; // this variable holds a single character

int blindmouse[3]; // declares blindmouse[0], blindmouse[1] and blindmouse[2]


See the Arduino Reference (under Help in the Arduino IDE) for a list of operators.


x = (a + b) / c;


if ( a == 0 ) then { ….}

if (x >= 0 && x < 10} then { …. } else { …. }


while ( sum < max ) do { …. }

for (i=0; i<10; i++) { ….} // The same as i = 0; while (i < 10) { ….; i = i+1; }

break; // Exit immediately from the smallest surrounding loop

continue; // Go back to the top of the smallest surrounding loop and start the next time round.


  • A function has a type, but if it just does a job and doesn't return anything the type is void.
  • We have to declare the type of the parameters (length and breadth), to which are assigned the values given in the function call.
  • See the Arduino Reference for standard functions you can use.

float area(float length, float breadth) {

 return length * breadth;


roomsize = area(6, 9);

Previous article Arduino - Buying Guide
Next article Lightino Lesson 5: How fast is it spinning?

Check out our latest products...

64Gb Micro Sd Card Memory - Class 10 With Adapter - Accessories And Breakout Boards
Resistor Colour Codes - Educational Poster - Education
Picade X Hat - Raspberry Pi Boards

Picade X HAT

£15.00 inc VAT
£12.50 ex VAT
Ohms Law - Educational Poster - Education
Pimoroni Raspberry Pi 3 B+ Starter Kit - Raspberry Pi Kits

Pimoroni Raspberry Pi 3 B+ Starter Kit

£89.99 inc VAT
£74.99 ex VAT
Touch:bit - Micro:bit


£10.00 inc VAT
£8.33 ex VAT
Tinkerkit Braccio Robotic Arm For Arduino - Robot

Tinkerkit Braccio Robotic Arm for Arduino

£197.99 inc VAT
£164.99 ex VAT
Arduino Yún Rev 2 - Dev Boards

Arduino Yún Rev 2

£51.59 inc VAT
£42.99 ex VAT