DDRA =0xFF or DDRA =0b11111111.
Where:
PORTA |= (1<<7) or PORTA |= (0b10000000)
PORTA |= PORTA &= ~(1<<7) or PORTA &= ~(0b10000000)
/*
* led_blink.c
*
* Rohan Rege
*
*/
#define F_CPU 20000000 //Define clcok speed as 20Mhz
#include <avr/io.h> //Import header file required for AVR microcontrollers
#include <util/delay.h> //Import header flie required for delay function
int main(void)
{
DDRA = 0b10000000; //set PA7 as output
while (1) //Infinite Loop
{
PORTA |= (1<<7); // Set PA7 high (Make LED ON)
_delay_ms(5000); //delay of 5 sec
PORTA &= ~(1<<7); // Set PA7 low (Make LED OFF)
_delay_ms(5000); //delay of 5 sec
}
}
To flash this program, I've used Atmel Studio on windows.
ADD R16, R17 ; Add value in R16 to value in R17
DEC R17 ; Minus 1 from the value contained in R17
MOV R18, R16 ; Copy the value in R16 to R18
END: JMP END ; Jump to the label END
I have used the cbi and sbi to directly modify the registers.
.device attiny44
.org 0
sbi DDRA,0
loop:
sbi PORTA,0
cbi PORTA,0
rjmp loop
/*
led_blink.ino
Rohan Rege
*/
void setup() {
pinMode(PA7, OUTPUT);
}
void loop() {
digitalWrite(PA7, HIGH);
delay(300);
digitalWrite(PA7, LOW);
delay(300);
}
import GPIO as g
#importing the general purpose input/output pin control library and renaming it as 'g'import time
#importing the time libraryg.setmode(g.BCM)
#setting the pin layout based on BCM rather than normal numberingg.setup(18 , g.out)
#defining the output pinprint "led On"
#Printing the LED ON in terminalg.output(18 , g.HIGH)
#Turning the output HIGHtime.sleep(1)
#Sleeping for 1sprint "led Off"
#Printing led off on screeng.output(18 , g.LOW)
#turning the output LOW
import GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.IN)
while True:
if(GPIO.input(13)):
GPIO.output(11, True)
time.sleep(0.1)
GPIO.output(11, False)
time.sleep(0.1)