0

Line Robot - Basic lessons - Display

ML-R 8x8 bicolor display, CAN Bus,UART, 4 switches (mrm-8x8a) can be used to display stored bitmaps (images) or custom ones. Stored ones are easier so we will teach You here how do that. This program will show the idea:
void RobotLine::loop() {
	if (millis() % 1000 < 500)
		sign(65);
	else
		sign(66);
}
C++ operator "%" means "remainder" after division. If we divide an integer with 1000, remainder can be 0..999. Let's assume that the program starts at 5000 ms. Remainder will be increasing (as milliseconds increase), but will be less than 500, until 5500 ms elapses. During this time, the "if" will evaluate "true" and the first instruction will execute. After the remainder reaches 500, the "if" will not be true anymore, therefore executing "else" part.

A short form of the display command is:
sign(address);
where address is ASCII character code. Use Google to learn more about ASCII. You will see that letter "A" is coded as 65, and "B" as 66. Hence, the 2 sign() instructions in our program will print alternating characters "A" and "B".
As C++ converts a character into its ASCII code, at least here, You can write the same program with characters, in single quotes, instead of their ASCII codes:
void RobotLine::loop() {
	if (millis() % 1000 < 500)
		sign('A');
	else
		sign('B');
}

Task: print more characters.

Study ASCII table to find characters of the first 5 letters: A, B, C, D, and E. Display them in a sequence, each 0.5 sec.