ATmega128 pins

untitled.pdf (40747Bytes)

Hello,

I am not familiar with ATmega, so I need a little help.

I need to use 35 pins of ATmega128 just for sensors ,4 motors control and 3 LED's of my robot.

Okay, here is my list:

##(two motors with PWM control and two without)####

PWM 1------------1—digital----------------------------------PB5

Forward 1---------2—Digital---------------------------------PE2

Reverse 1---------3—Digital---------------------------------PE3

 

PWM 2------------4—Digital---------------------------------PB6

Forward 2---------5—Digital---------------------------------PE4

Reverse 2---------6—Digital---------------------------------PE5

 

Forward 3---------7—Digital---------------------------------PE6

Reverse 3---------8—Digital---------------------------------PE7

 

Forward 4---------9—Digital--------------------------------PA6

Reverse 4---------10- Digital--------------------------------PA7

##(3 IR encoder)###########

wh.encod_1-------11- Digital------------------------------PA3

wh.encod_2-------12- Digital-------------------------------PA4

encod_3------------13- Digital------------------------------PA5

###(color recognition with LDR)###

 LDR-1---------------14-analog-------------------------------PF0

##(Bump sensor - tactile switch)##

 Bump_sens_1----15- analog----------------------------PF1

Bump_sens_2----16- analog------------------------------PF2

##(Simple IR obsticle sensor)#####

 Obst_sens_1------17- analog------------------------------PF3

Obst_sens_2------18- analog------------------------------PF4

##(HC-SR04 ultrasound sensors)###

 Sonar_1-----------19- Digital--------------------------------PA0

Sonar_2-----------20- Digital---------------------------------PA1

Sonar_3-----------21- Digital---------------------------------PA2

##( 8 IR Line sensors)############

 Sens_1------------22- Digital---------------------------------PC0

Sens_2------------23- Digital---------------------------------PC1

Sens_3------------24- Digital---------------------------------PC2

Sens_4------------25- Digital---------------------------------PC3

Sens_5------------26- Digital---------------------------------PC4

Sens_6------------27- Digital---------------------------------PC5

Sens_7------------28- Digital---------------------------------PC6

Sens_8------------29- Digital---------------------------------PC7

##(Motor breaking)##########

 Stop_m_1---------30- digital or analog?---------------PB2

Stop_m_2---------31- digital or analog?---------------PB3

Stop_m_3---------32- digital or analog?---------------PB4

##(Red, Green, Blue LED's)###

R_Led-------------33-Digital---------------------------------PD4

G_Led-------------34-Digital---------------------------------PD5

B_Led-------------35-Digital---------------------------------PD6

 

From the left:

Sensor or motor or LED -> number -> signal mode -> ATmega128 pin    

 

 

So, do You have any advices in choosing right pins of ATmega128. Or maybe I chose wrong pins and made mistakes?

Also I dont want to block my way in future inprovements (like connecting second processor as slave, o using GPS...)

Thank-You a lot for Your help 

 

ps.

 Here is a Pin configurations of ATmega128:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ps2. By the way. I am not sure if I can use LM358N in wheel encoder circuit like that. (middle circuit)