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