In this C language course, we’ll learn how to program to control embedded systems.
This course is aimed at people who are not familiar with electronic board programming in C.
This course can also be very useful for those who have already made programs in C but want to focus more on hardware: knowing which types of variables take up the least space in memory, or how to switch on an LED.
To program, we’ll use microchip’s MPLAB IDE software to simulate and download the program directly onto the circuit board.
If you’d like to program electronic boards easily, especially Arduino boards, take a look at our courses on the Arduino language.
We’re now going to take a look at the basics of the C language to get you started.
La première chose que l’on voit quand on ouvre un programme est le void main :
#include <stdio.h>
void main(){
//Your progam
}
The main function is the main function of your program. This is where you put all the program instructions or function calls you need.
The void main is mandatory, as failure to include it will result in an error.
Every function starts with an open bracket ({) and ends with a closed bracket (}):
#include <stdio.h>
void main(){
my_function();
}
void my_function {
}
Failure to use the square brackets will result in an error.
The last thing we’re going to look at is the semicolon. In the C language, all instructions always end with a semicolon:
#include <stdio.h>
void main(){
my_function(); // We call the my_function which is an intruction so semicolon
}
void my_function {
}
Failure to use a semicolon will result in an error.
We’ll now take a short quiz to test your knowledge of the C language.
A) A pre-written source file containing ready-to-use functions
B) A file containing function names, their signatures and the type of return code
C) A file containing a program
A) A program that runs only on the system console
B) A program that runs on a virtual terminal in a graphical window
C) A program that runs in a graphical environment with windows
A) Serial.println(“message”);
B) printf(“message”);
C) fprintf(“message”);
A) \a
B) \r
C) \n
A) The programmer
B) The interpreter
C) The compiler
A) The hard disk
B) Microprocessor
C) RAM
A) juju
B) juju-5
C) juju_5
A) int
B) unsigned int
C) double
A) scanf(“%f”,decimal_number);
B) scanf(“%lf”, *decimal_number);
C) scanf (%f” ,&decimal_number);
A) Ceil
B) Round
C) Pow
Here are the answers to the quiz: 1)A), 2)A) , 3)B), 4)c), 5)c), 6)C), 7)B), 8)A), 9)C), 10)B).
Don’t worry if you had trouble answering the questions, you can take a look at our Embedded C language courses, which will help you with your programming!