Hi
I am new to Programming and Microcontrollers
I want to make 16 line Input to 4 Line output ENCODED by ATmega328 Microcontroller
I have 2 New ATmega328 Microcontrollers (Without Bootloader).
I have Arduino Board with ATmega328 Kit.
do I need extra Programmer to Program the Atmega328 Microcontroller?
if not. How to program the other ATmega328 with the ARDUINO 328 Kit???
please Help
The code I prepared are as follows:-
these are Written in ARDUINO IDE V1.0.5
is this code ok for the 16x4 Encoder if not
please help
I am new to Programming and Microcontrollers
I want to make 16 line Input to 4 Line output ENCODED by ATmega328 Microcontroller
I have 2 New ATmega328 Microcontrollers (Without Bootloader).
I have Arduino Board with ATmega328 Kit.
do I need extra Programmer to Program the Atmega328 Microcontroller?
if not. How to program the other ATmega328 with the ARDUINO 328 Kit???
please Help
The code I prepared are as follows:-
Rich (BB code):
//16 x 4 Line Encoder
// 16 input
const int tr_01Pin = 1; // Input From Tr. BC547- 01
const int tr_02Pin = 2; // Input From Tr. BC547- 02
const int tr_03Pin = 3; // Input From Tr. BC547- 03
const int tr_04Pin = 4; // Input From Tr. BC547- 04
const int tr_05Pin = 5; // Input From Tr. BC547- 05
const int tr_06Pin = 6; // Input From Tr. BC547- 06
const int tr_07Pin = 9; // Input From Tr. BC547- 07
const int tr_08Pin = 10; // Input From Tr. BC547- 08
const int tr_09Pin = 11; // Input From Tr. BC547- 09
const int tr_10Pin = 12; // Input From Tr. BC547- 10
const int tr_11Pin = 13; // Input From Tr. BC547- 11
const int tr_12Pin = 14; // Input From Tr. BC547- 12
const int tr_13Pin = 15; // Input From Tr. BC547- 13
const int tr_14Pin = 16; // Input From Tr. BC547- 14
const int tr_15Pin = 17; // Input From Tr. BC547- 15
const int tr_16Pin = 18; // Input From Tr. BC547- 16
//BCD OUTPUT (A B C D as 0 0 0 0 - 1 1 1 1)
const int OUT_A = 25; // Output From A
const int OUT_B = 26; // Output From B
const int OUT_C = 27; // Output From C
const int OUT_D = 28; // Output From D
void setup()
{
pinMode(tr_01Pin,INPUT); // 0000
pinMode(tr_02Pin,INPUT); // 0001
pinMode(tr_03Pin,INPUT); // 0010
pinMode(tr_04Pin,INPUT); // 0011
pinMode(tr_05Pin,INPUT); // 0100
pinMode(tr_06Pin,INPUT); // 0101
pinMode(tr_07Pin,INPUT); // 0110
pinMode(tr_08Pin,INPUT); // 0111
pinMode(tr_09Pin,INPUT); // 1000
pinMode(tr_10Pin,INPUT); // 1001
pinMode(tr_11Pin,INPUT); // 1010
pinMode(tr_12Pin,INPUT); // 1011
pinMode(tr_13Pin,INPUT); // 1100
pinMode(tr_14Pin,INPUT); // 1101
pinMode(tr_15Pin,INPUT); // 1110
pinMode(tr_16Pin,INPUT); // 1111
pinMode(OUT_A,OUTPUT);
pinMode(OUT_B,OUTPUT);
pinMode(OUT_C,OUTPUT);
pinMode(OUT_D,OUTPUT);
}
void loop()
{
if(tr_01Pin == 0) // 0000 = 00
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_02Pin == 1) // 0001 = 01
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_03Pin == 1) // 0010 = 02
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_04Pin == 1) // 0011 = 03
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_05Pin == 1) // 0100 = 04
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_06Pin == 1) // 0101 = 05
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_07Pin == 1) // 0110 = 06
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_08Pin == 1) // 0111 = 07
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 0; // BCD OUTPUT
}
else
if(tr_09Pin == 1) // 1000 =08
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_10Pin == 1) // 1001 = 09
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_11Pin == 1) // 1010 = 10
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_12Pin == 1) // 1011 = 11
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 0; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_13Pin == 1) // 1100 = 12
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_14Pin == 1) // 1101 = 12
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 0; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_15Pin == 1) // 1110 = 14
{
OUT_D == 0; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
else
if(tr_16Pin == 1) // 1111 = 15
{
OUT_D == 1; // BCD OUTPUT
OUT_C == 1; // BCD OUTPUT
OUT_B == 1; // BCD OUTPUT
OUT_A == 1; // BCD OUTPUT
}
}
is this code ok for the 16x4 Encoder if not
please help
Last edited: