Advertisement
MR_Rednax

basis code school

Apr 26th, 2024
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <IRremote.h>
  2. #include <ir_Lego_PF_BitStreamEncoder.h>
  3. #include <LCD-I2C.h>
  4. #include <AccelStepper.h>
  5. #include <Wire.h>
  6.  
  7.  
  8. #define blue_button 3
  9. #define black_button 2
  10. #define setpper_1 4
  11. #define setpper_2 5
  12. #define setpper_3 6
  13. #define setpper_4 7
  14. #define FULLSTEP 4
  15. #define ir_input 9
  16.  
  17. IRrecv IrReceiver(ir_input);
  18. LCD_I2C lcd(0x27, 16, 2);
  19.  
  20. AccelStepper stepper(FULLSTEP, 7, 5, 6, 4);
  21.  
  22. void setup(){
  23.   //#======pin=setup=========#//
  24.       pinMode(blue_button, INPUT);
  25.       pinMode(black_button, INPUT);
  26.      
  27.   //#======LCD=setup=========#//
  28.       lcd.begin();
  29.       lcd.clear();    
  30.       lcd.display();
  31.       lcd.setCursor(0, 0);
  32.       lcd.print("starting");
  33.       lcd.backlight();
  34.  
  35.   //#======serial_begin======#//
  36.       Serial.begin(9600);
  37.  
  38.   //#=======stepper==========#//
  39.       stepper.setMaxSpeed(600);
  40.       stepper.setSpeed(600);
  41.       stepper.setAcceleration(100.0);
  42.       stepper.moveTo(500);
  43.      
  44.   //#=====start=secuence=====#//
  45.       delay(2000);
  46.       lcd.clear();
  47.       lcd.print("done");
  48.       delay(700);
  49.       lcd.clear();    
  50. }
  51.  
  52. void loop(){
  53.   if (stepper.distanceToGo() == 0)
  54.       stepper.moveTo(-stepper.currentPosition());
  55.   stepper.run();
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement