Advertisement
Giuseppe99999

Micro-Chip programmazione in C Giuseppe Ferlante

Jun 26th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.47 KB | None | 0 0
  1. /*
  2. Autore Giuseppe Ferlante
  3. Città:Gela,Sicilia,Cl
  4.  
  5.     <one line to give the program's name and a brief idea of what it does.>
  6.     Copyright (C) 2015  Giuseppe Ferlante
  7.  
  8.     This program is free software: you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation, either version 3 of the License, or
  11.     (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20. */
  21.  
  22. #define F_CPU 16000000  //16Mhz ,max:20Mhz
  23. #include <avr/io.h>
  24. #include <util/delay.h>
  25. int main(void)
  26. {
  27.     DDRB |= 0x16;//output led 010000  , 5* led = 12
  28.     DDRD &= 0x40;//per pulsante INPUT  1000000 = 0x40 , 7 pin
  29.     //PORTD |= 0x01;
  30.     PORTB &=0x00;//spegne led
  31.     while(1)
  32.     {
  33.         if(bit_is_clear(PIND,7)==0)// se il pulsante è premuto
  34.         {
  35.             PORTB |=0x16;//accendo Led
  36.         }
  37.         else
  38.         {
  39.             PORTB &=0x00; //spengne :D
  40.         }
  41.     }
  42. }
  43. /*
  44. PROGRAMMARE ATMEGA-328P , micro-Chip , CPU:8 bit AVR .
  45. Facendo pressione sul pulsante collegato alla porta digitale '7' accende il led collegato alla porta digitale '12';
  46. GIORNI per studiare impiegati:3.
  47. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement