Hi there!
I am having trouble with this little line error that is stoping me from mapping the number of followers of a given Instagram account into the servo position (working on ESP32 board).
I would highly appreciate any help from you as I cannot get through for the past 3 days.
Best!
Code:/******************************************************************* * An exa - Pastebin.com
/*******************************************************************
* An example of usisng the InstagramStats library to get
* info on a given user
*
* Written by Brian Lough
* https://www.youtube.com/channel/UCezJOfu7OtqGzd5xrP3q6WA
*******************************************************************/
#include "InstagramStats.h"
#include "Arduino.h"
#include <Servo.h>
Servo servo1;
// ----------------------------
// Standard Libraries - Already Installed if you have ESP32 set up
// ----------------------------
#include <WiFi.h>
#include <WiFiClientSecure.h>
//LED setup
#define GREENPIN 38
#define FADESPEED 5
//Servo
static const int servoPin = 5;
static const int potentiometerPin = 14;
int value;
int followedByCount;
// ----------------------------
// Additional Libraries - each one of these will need to be installed.
// ----------------------------
#include "JsonStreamingParser.h"
// Used to parse the Json code within the library
// Available on the library manager (Search for "Json Streamer Parser")
// https://github.com/squix78/json-streaming-parser
//------- Replace the following! ------
char ssid[] = "iPhone Maciek"; // your network SSID (name)
char password[] = "o9h2gott"; // your network key
WiFiClientSecure client;
InstagramStats instaStats(client);
unsigned long delayBetweenChecks = 20000; //mean time between api requests
unsigned long whenDueToCheck = 0;
//Inputs
String userName = "najadeostos"; // from their instagram url https://www.instagram.com/brian_lough/
void setup() {
Serial.begin(115200);
servo1.attach(servoPin);
// Attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
IPAddress ip = WiFi.localIP();
Serial.println(ip);
}
void getInstagramStatsForUser() {
Serial.println("Getting instagram user stats for " + userName );
InstagramUserStats response = instaStats.getUserStats(userName);
Serial.println("Response:");
Serial.print("Number of followers: ");
Serial.println(response.followedByCount);
}
void loop() {
unsigned long timeNow = millis();
if ((timeNow > whenDueToCheck)) {
getInstagramStatsForUser();
whenDueToCheck = timeNow + delayBetweenChecks;
}
int value = response.followedByCount;
int servoPosition = map(value, 166, 170, 0, 180);
servo1.write(servoPosition);
Serial.println(servoPosition);
delay(20);
}
/* int value = (response.followedByCount);
follows = map(value, 166, 170, 0, 255);
analogWrite(GREENPIN, follows);
delay(FADESPEED); */
Arduino: 1.8.7 (Windows 10), Board: "WIFI_Kit_32, 80MHz, 921600"
C:\Users\tomak\Documents\Arduino\UserData_led_intensity_from_follows\UserData_led_intensity_from_follows.ino: In function 'void loop()':
UserData_led_intensity_from_follows:92:17: error: 'response' was not declared in this scope
int value = response.followedByCount;
^
exit status 1
'response' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


