Skip to content

Batoul Omar Al-Rashdan 8. Final Code
Type to start searching
    • Home
    • Final project
    • About
    • Assignments
    • Home
      • 1. Summary
      • 2. Concept
      • 3. Research
      • 4. Design Thinking
      • 5. Bill of Material
      • 6. Input & it's packaging
      • 7. Output & it's packaging
      • 8. Final Code
      • 9. Future Improvements
      • About me
      • Student Agreement
      • 1. Principles and Practices - glove controller for output devices (Art)
      • 2. Project Management
      • 3. Computer Aided design
      • 4. Computer controlled cutting
      • 5. Electronics production
      • 6. 3D Scanning and printing
      • 7. Electronics design
      • 8. Computer controlled machining
      • 9. Embedded programming
      • 10. Input Devices
      • 11. Applications and Implications
      • 12. Output devices
      • 13. Interface and Application Programming
      • 14. Invention, Intellectual Property, and Income
      • 15. Networking and Communications
      • 16. Molding and Casting
      • 17. Wildcard week
      • 18. Machine week
      • 19. Project development

    8. Final Code¶

    Servo- Flex code … for my final project

    #include <Servo.h>
    
    Servo myServo;
    int flexValue;
    int servoPosition;
    const int flexPin = A0;
    
    void setup()
    {
      myServo.attach(6);
      Serial.begin(9600);
    }
    
    void loop()
    {
    
    
      flexValue = analogRead(flexPin);
    
      servoPosition = map(flexValue, 450 , 1023 , 0, 125);
      servoPosition = constrain(servoPosition, 0, 125);
      Serial.println(flexValue);
     // Serial.println(servoPosition);
      myServo.write(servoPosition);
    
      delay(100);
    }
    
    Previous 7. Output & it's packaging
    Next 9. Future Improvements
    Creative Commons Attribution Non Commercial
    powered by MkDocs and Material for MkDocs