Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- for (int i=4;i<=7;i++){
- pinMode(i,OUTPUT);
- }
- }
- int quotient = 0;
- int x = 0;
- void loop(){
- function2();
- encode();
- Serial.println(analogRead(A0));
- }
- void function1() {
- // put your main code here, to run repeatedly:
- x=16*millis()/500;
- quotient=x%16;
- }
- void function2(){
- x=millis()/1000;
- if (x%2==0)
- quotient=15*(millis()%1000)/1000;
- else
- quotient = 15-15*((millis()%1000))/1000;
- }
- void encode(){
- for (int i=4;i<=7;i++){
- digitalWrite(i,quotient%2);
- quotient=quotient/2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement