#!/bin/bash

#CON1 - 23
#CON2 - 112
#CON3 - 67
#DATA1 - 32
#DATA2 - 14


cd /sys/class/gpio/
sudo chmod 777 export
sudo chmod 777 unexport
sudo echo 23 > export
cd gpio23
sudo chmod 777 direction
sudo chmod 777 value
sudo echo out > direction


#COMMAND(2)
echo "TX--->COMMAND(2)"
sudo echo 0 > value



#COMMAND(1)
echo "TX--->COMMAND(3)"
sudo echo 1 > value
sleep 0.05

#WRITE_DATA(2130) -
echo "TX--->WRITE_DATA(2130)-"
cd /sys/class/gpio/
sudo chmod 777 export
sudo chmod 777 unexport
sudo echo 32 > export
sudo echo 112 > export
sudo echo 67 > export
sudo echo 14 > export
cd gpio32
sudo chmod 777 direction
sudo chmod 777 value
sudo echo out > direction
cd ../gpio67
sudo chmod 777 direction
sudo chmod 777 value
sudo echo out > direction
cd ../gpio112
sudo chmod 777 direction
sudo chmod 777 value
sudo echo out > direction
cd ../gpio14
sudo chmod 777 direction
sudo chmod 777 value
sudo echo in > direction

#write 2(0010)
echo "TX--->WRITE_DATA(2130):TX 2"
cd ../gpio112
echo 0 > value
sleep 0.05
cd ../gpio67
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05


cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value

sleep 0.05
cd ../gpio112
sleep 0.05
echo 1 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value

sleep 0.05
cd ../gpio112
sleep 0.05
echo 0 > value
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

#write 1(0001)
echo "TX--->WRITE_DATA(2130):TX 1"
cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
echo 1 > value
sleep 0.05
echo 0 > value

sleep 0.05
cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value

sleep 0.05
cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value

sleep 0.05
cd ../gpio112
sleep 0.05
echo 1 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value

sleep 0.05
cd ../gpio32
sleep 0.05
echo 1 > value
sleep 0.05

#write 3(0011)
echo "TX--->WRITE_DATA(2130):TX 3"
cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05


cd ../gpio112
sleep 0.05
echo 1 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

cd ../gpio112
sleep 0.05
echo 1 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

#write 0(0000)
echo "TX--->WRITE_DATA(2130):TX 0"
cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

cd ../gpio112
sleep 0.05
echo 0 > value
sleep 0.05
cd ../gpio67
sleep 0.05
echo 1 > value
sleep 0.05
echo 0 > value
sleep 0.05

cd ../gpio32
sleep 0.05
echo 0 > value
sleep 0.05

#de-initi all the GPIOS
cd ..
#sudo echo 23 > unexport
sudo echo 112 > unexport
sudo echo 67 > unexport
sudo echo 14 > unexport
sudo echo 32 > unexport

