I created a simple program to be put onto a ATMega328P chip (Datasheet). I wrote my first program in ATMEL studio that I wanted to use to Blink an LED at a rate of 0.5Hz with extremely low power usage. Here's my code:
/*
* GccApplication1.c
*
* Created: 11/12/2017 8:56:49 PM
* Author : Brice
*/
#include <avr/io.h>
#include <util/delay.h>
#include <avr/power.h>
int main(void)
{
clock_prescale_set(clock_div_128); //set the clock to use the 8MHz internal clock divided by 128 for an internal frequency of 250KHz, consumes 0.4mA while not sleeping.
while (1)
{
PORTD4 == 1;//Set pin 13 of the micro to high.
_delay_ms(1000);
PORTD4 == 0;//Set pin 13 of the micro to low;
_delay_ms(1000);
}
}
What I expect this code to do to this micro-controller is to turn PORTD register 4 on for 1 second, then turn it off for a second.
currently, The PortD4 will not have any voltage changes to it, and remains grounded while the device is powered.
Any explanation of this would be appreciated!
For this instance, I'm using the Arduino Pro mini board for prototyping..
pin 4 of the Pro mini is connected to the common Anode of an RGB led, and the G pin of the LED is connected from a 510 Ohm resistor to GND. I've tested the wiring with a working arduino, and the led even lights at 3.3 Volts pretty brightly.
PORTD4 == 1; //CHECK IF pin 13 of the micro to high
. It doesn't set pin 13. \$\endgroup\$