MQTT Cover sketch for blind tilt

I’ve setup everything for my first attempt to control my window blinds with an ESP8266 and a servo and in all reality I will only use the tilt function as these blinds are never opened as such, but I’m having trouble trying to mess around with sketches to get it to load right onto the NodeMCU.

Anyone have a link to a simple sketch that might help?

If you are using the Arduino IDE the following settings will work with the NodeMCU…

image

You would need to set the board up first tho’.

I have it all setup in Arduino IDE, it’s just the sketch I’ve used is now so messed up with changes I’ve tried to make I think I’m better off starting with a new one

This is from the starter kit set of sketches …

/*
  Arduino Starter Kit example
 Project 5  - Servo Mood Indicator

 This sketch is written to accompany Project 5 in the
 Arduino Starter Kit

 Parts required:
 servo motor
 10 kilohm potentiometer
 2 100 uF electrolytic capacitors

 Created 13 September 2012
 by Scott Fitzgerald

 http://www.arduino.cc/starterKit

 This example code is part of the public domain
 */

// include the servo library
#include <Servo.h>

Servo myServo;  // create a servo object

int const potPin = A0; // analog pin used to connect the potentiometer
int potVal;  // variable to read the value from the analog pin
int angle;   // variable to hold the angle for the servo motor

void setup() {
  myServo.attach(9); // attaches the servo on pin 9 to the servo object
  Serial.begin(9600); // open a serial connection to your computer
}

void loop() {
  potVal = analogRead(potPin); // read the value of the potentiometer
  // print out the value to the serial monitor
  Serial.print("potVal: ");
  Serial.print(potVal);

  // scale the numbers from the pot
  angle = map(potVal, 0, 1023, 0, 179);

  // print out the angle for the servo motor
  Serial.print(", angle: ");
  Serial.println(angle);

  // set the servo position
  myServo.write(angle);

  // wait for the servo to get there
  delay(15);
}