Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************
- * 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;
- // ----------------------------
- // 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 = read(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:91:22: error: 'response' was not declared in this scope
- int value = read(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.
Add Comment
Please, Sign In to add comment