CLIL - Praktická cvičení

(Rozdíly mezi verzemi)
Přejít na: navigace, hledání
Řádka 1: Řádka 1:
 +
== exercise with MCU ==
  
  
 +
[[Soubor:Newbiehack.jpg]]
 +
 +
== Microcontroller - A Beginners Guide ==
 +
 +
<gallery>
 +
Soubor:AVR-PRG-01.jpg|[[Vývojová deska ATMEL včetně AVR ATmega16 v2|VYV50 Vývojová deska ATMEL (ATmega16) v2]]
 +
soubor:logo_winavrR.png|[[Soubor:Icon-pdf.gif]] [http://winide51.wz.cz/downloads/avr/manual.pdf WinAVR]
 +
soubor:logo_AVR.png|[[AVR Studio]]
 +
soubor:logo_CVAVR.jpg|[[CodeVisionAVR]]
 +
</gallery>
 +
 +
====Understanding Button Debouncing ====
 +
 +
[http://newbiehack.com/UnderstandingButtonDebouncing.aspx original link]
 +
 +
{{#widget:YouTube|height=180|width=240|id=Iby888ZXpZ8}}
 +
 +
<source lang"C">
 +
#include <avr/io.h>
 +
int main(void)
 +
{
 +
DDRB |= 1 << PINB0; //Set Direction for output on PINB0
 +
PORTB ^= 1 << PINB0; //Toggling only Pin 0 on port b
 +
DDRB |= 1 << PINB2; //Set Direction for Output on PINB2
 +
DDRB &= ~(1 << PINB1); //Data Direction Register input PINB1
 +
PORTB |= 1 << PINB1; //Set PINB1 to a high reading
 +
int Pressed = 0; //Initialize/Declare the Pressed variable
 +
 +
while (1)
 +
{
 +
  if (bit_is_clear(PINB, 1)) //Check is the button is pressed
 +
  {
 +
  //Make sure that the button was released first
 +
      if (Pressed == 0)
 +
      {
 +
          PORTB ^= 1 << PINB0; //Toggle LED in pin 0
 +
          PORTB ^= 1 << PINB2; //Toggle LED on pin 2
 +
          Pressed = 1;
 +
      }
 +
  }
 +
else
 +
  {
 +
//This code executes when the button is not pressed.
 +
Pressed = 0;
 +
  }
 +
}
 +
}
 +
 +
</source>
  
 
== exercise with NXT ==
 
== exercise with NXT ==

Verze z 26. 1. 2013, 12:58

Obsah

exercise with MCU

Newbiehack.jpg

Microcontroller - A Beginners Guide

Understanding Button Debouncing

original link

#include <avr/io.h>
int main(void)
{
DDRB |= 1 << PINB0; //Set Direction for output on PINB0
PORTB ^= 1 << PINB0; //Toggling only Pin 0 on port b
DDRB |= 1 << PINB2; //Set Direction for Output on PINB2
DDRB &= ~(1 << PINB1); //Data Direction Register input PINB1
PORTB |= 1 << PINB1; //Set PINB1 to a high reading
int Pressed = 0; //Initialize/Declare the Pressed variable
 
while (1)
 {
   if (bit_is_clear(PINB, 1)) //Check is the button is pressed
   {
   //Make sure that the button was released first
       if (Pressed == 0) 
       {
          PORTB ^= 1 << PINB0; //Toggle LED in pin 0
          PORTB ^= 1 << PINB2; //Toggle LED on pin 2
          Pressed = 1;
       }
   }
else
  {
//This code executes when the button is not pressed.
Pressed = 0;
  }
 }
}

exercise with NXT


maybe:


Osobní nástroje
Jmenné prostory
Varianty
Akce
Rychlá navigace
NEJ aktivity
Nejlepší předměty
Nejlepší MCU
SW-HW
Ostatní
Utility
Nástroje
Tisk/export