MiniMexleIO
From RoboWiki
The usual "Hello, World!" program in the area of the single chip microcontrollers is to connect a pushbutton and LED and to control them.
We already have the pushbutton and the LED on the MiniMexle board, so here is an excerpt from the whole schematics
And here is a short C-code for controlling them:
#include <avr\io.h>
int main()
/* ***************** Initialization ************************ */
/* Port settings for LED *********************************** */
DDRB = 0b00000100; // bin: 0000 0100 1 = out, 0 = in
PORTB = 0xFF; // bin: 1111 1111 1 = LED zhasni
/* Port settings for Switch ******************************** */
DDRB = 0b00000100; // bin: 0000 0100 1 = out, 0 = in
PORTB = 0xFF; // bin: 1111 1111 1 = LED zhasni
{
while (1) {
if (PORTA&&0x0F) then
PORTD = 0x01;
else
PORTD = 0x01;
}
}
Task:
The task is to control the on and off state of the LED with a single button. First press of the button will set LED on, second press off. Hint: You will need a memory to store the actual LED state to change it.