Hi, I'm not completely sure on etiquette here, I was going to post in another topic called "AVR beginner", but the forum engine shouted at me with red letters asking if I was really sure I wanted to post there.
For quite some time I've been wanting to move into the world of the smaller MCUs, PIC12F and Attiny13s or 85s, and moving my Arduino projects onto small homemade PCBs.
But as with so much in electronics I'm finding the transition from "Easy" to skip "Medium" and go straight to "Hard".
It might be best if I mention the simple project at hand as it is for Arduino.
It's a simple PWM dimmer for my chicken coop based on time from a RTC chip via I
2C.
#include <Wire.h>
#include "DS3231.h"
RTClib RTC;
const int ledPin = 9; // LED connected to digital pin 9
int hourValue; // Timeverdi
int minuteValue; // Minuttverdi
int ledValue; // PWM duty cycle 0-255, 0%-100%
void setup() {
Serial.begin(57600);
Wire.begin();
}
void loop() {
delay(10000);
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
hourValue = (now.hour());
minuteValue = (now.minute());
if (hourValue >= 22 && hourValue < 6)
{
ledValue = 0; // nighttime
}
else if (hourValue == 6)
{
ledValue = minuteValue * 4.2 ; // dims up during 6. hour
}
else if (hourValue >= 7 && hourValue < 11)
{
ledValue = 255 ; // from 7-11 the light is fully on
}
else if (hourValue >= 11 && hourValue < 18)
{
ledValue = 0 ; // daylight, light redundant
}
else if (hourValue >= 18 && hourValue < 21)
{
ledValue = 255 ; // daylight fades, light takes over
}
else if (hourValue == 21)
{
ledValue = 255 - (minuteValue * 4.2) ; // dim down during 21. hour
}
analogWrite(ledPin, ledValue);
}
My main problem is with Atmel Studio 7.
I don't understand how to find what libraries, if any, it has?
From what I gather, TWI is something that needs adding so I found a library for Attiny and I think I got it where it needs to go.
https://www.eevblog.com/forum/microcontrollers/good-usi-i2c-master-slave-attiny85-library-(optionally-master-arbitration-)/After reading the documentation for the Attiny85 and getting nothing but red eyes I decided I was missing the bigger picture and most of all the order of things.
I suppose including libraries and defining pins comes first.
"io.h" is added automatically, so I guess AS7 has that.
But in this tutorial even "delay.h" has to be included:
http://www.avr-tutorials.com/interfacing/interfacing-leds-avr-microcontroller -So that is built into AS7?
I don't even know what to ask right now, my head is fuzzy. Is Atmel Studio even usable as-is or is it just a hollow shell that needs filling?