Programming ATMEGA16A PU with Arduino

I am trying to upload my arduino code inside of ATMGE16A PU microcontroller. I searched so many source about that but I just can load blinky code. It was worked but if,else, while .... loops doesnt worked . Anyone know the truth circuit diagram and how can I load my code ?

This was the method i tried and it didn't work: 1-) Programmed my arduino uno with Arduino ISP code Programmer: AVRISP MKLL
2-) Connected my circuit diagram as the screenshot below.
3-)Tried to burn bootloader (doesnt work ), and tried to direct load (doesnt worked too)
4-) Removed 22mF capacitors and i could load my code but now IF ELSE loopes doesnt works well or doesnt works sometimes.

Thanks for helping guys :slight_smile:

Used Sources :How to Upload Arduino Code to ATMega16 Microcontroller (in Bahasa) - YouTube


dataSheet :http://ww1.microchip.com/downloads/en/devicedoc/atmel-8154-8-bit-avr-atmega16a_datasheet.pdf

We might be able to help if you post your code...

#include "PWM.h"
#define pedalPin //analog pin1
#define wheelAngle//analog pin2
#define speedMeter //analog pin3

//PWM FREKANS VE PİNLERİ//
//int pwm_pin1 = 9;
//int pwm_pin2 = 10;
//int32_t frekans = 16600;

//ANALOG DEĞER OKUNAN PİNLER//
int pedalValue;
int wheelAngleValue;
//int speedValue;
//direksiyon parametreleri//
//float right; //direksiyon sağ
//float left; //direksiyon sol
//float noDirection; //direksiyon orta

void setup() {
pinMode(9, OUTPUT); // sol motor
pinMode(10, OUTPUT);// sağ motor
Serial.begin(9600);

}

void loop() {
// pedalValue = analogRead(5);//pin1
pedalValue = analogRead(A1);
pedalValue = map(pedalValue, 0, 1023, 0 , 255); //1023 fitting 255
wheelAngleValue = analogRead(A0);//pin2
wheelAngleValue = map(wheelAngleValue, 0, 1023, 0 , 255); //1023 fitting 255
Serial.println(wheelAngleValue);
Serial.println(pedalPin);
// speedValue = analogRead(5);//pin3
//wheel rotate right sheesh
if (wheelAngleValue > 137)
{
analogWrite(9, pedalValue); // sol motor hız kontrol
analogWrite(10, pedalValue * 0); // sağ motor hız kontrol
}
//wheel rotate left sheesh
else if (wheelAngleValue < 117)
{

analogWrite(9, pedalValue * 0); // sol motor hız kontrol
analogWrite(10, pedalValue); // sağ motor hız kontrol

}
//wheel rotate middle sheesh
else if (117 <= wheelAngleValue <= 137)
{

analogWrite(9, pedalValue); // sol motor hız kontrol
analogWrite(10, pedalValue); // sağ motor hız kontrol

}
}

This is my code it works clearly on arduino but not works with ATMEL16A DIP integreted. I tested with blinky blinky works well but when I add simple If Else loop in code ATMEL16A doesnt works with loops.

Before I forget, I'm using a 20 mHz crystal for code load.

What does that mean?

if (117 <= wheelAngleValue <= 137)

not correct expression

"if" "else ""else if""while " commands doesnt works in atmel16a

didn't have any problems and when I tested the code with the potentiometer, I got the results I wanted. what kind of problem do you think is the "<" sign to be used? (tested with arduino uno not atmega16a)

#include "PWM.h"
#define pedalPin //analog pin1
#define wheelAngle//analog pin2
#define speedMeter //analog pin3

//PWM FREKANS VE PİNLERİ//
//int pwm_pin1 = 9;
//int pwm_pin2 = 10;
//int32_t frekans = 16600;

//ANALOG DEĞER OKUNAN PİNLER//
int pedalValue;
int wheelAngleValue;
//int speedValue;
//direksiyon parametreleri//
//float right; //direksiyon sağ
//float left; //direksiyon sol
//float noDirection; //direksiyon orta

void setup() {
  pinMode(9, OUTPUT); // sol motor
  pinMode(10, OUTPUT);// sağ motor
  Serial.begin(9600);

}

void loop() {
  // pedalValue = analogRead(5);//pin1
  pedalValue = analogRead(A1)>>2;
  //pedalValue = map(pedalValue, 0, 1023, 0 , 255); //1023 fitting 255
  wheelAngleValue = analogRead(A0)>>2;//pin2
  //wheelAngleValue = map(wheelAngleValue, 0, 1023, 0 , 255); //1023 fitting 255
  Serial.println(wheelAngleValue);
  Serial.println(pedalPin);
  // speedValue = analogRead(5);//pin3
  //wheel rotate right sheesh
  if (wheelAngleValue > 137)
  {
    analogWrite(9, pedalValue); // sol motor hız kontrol
    digitalWrite(10, 0); // sağ motor hız kontrol
  }
  //wheel rotate left sheesh
  else if (wheelAngleValue < 117)
  {

    digitalWrite(9, 0); // sol motor hız kontrol
    analogWrite(10, pedalValue); // sağ motor hız kontrol

  }
  //wheel rotate middle sheesh
  else 
  {

    analogWrite(9, pedalValue); // sol motor hız kontrol
    analogWrite(10, pedalValue); // sağ motor hız kontrol

  }
}

As @kolaha has said This statement is not valid...

... just replace with "else" or "if (117 <= wheelAngleValue && wheelAngleValue <= 137)"

Okay thanks for helping code but my realy problem is loading code in atmega16A :sweat_smile: Also this project not finished yet i'll add another else if parameters.

why is nano on schematic?

IDK. the man in the video used it. But its doesnt changes anything you can use uno too so I used too

What board are you telling the Arduino IDE you are programming? What do you have selected under "Tools -> Board:" when you upload the sketch?

I'd suggest that you use MCUDude's "MightyCore" instead of that "Gelatino" core...

image
i am using mighty core atmega16A
image

I am using MCUDude's "MightyCore"

изображение

8.4 (page 26 "atmel-8154-8-bit-avr-atmega16a_datasheet.pdf")
For resonators, the maximum frequency is 8 MHz with CKOPT unprogrammed and 16 MHz with CKOPT programmed.

I must have overlooked it.Should I try first 8mhz internal or external ? İ have arduino nanoV3 with 16mhz crytal also have external 20 mhz crystal.

wait, datasheet says atmega328 has maximum 20MHz, but ppl overclocked it up to 40MHz.
then... never mind