Guest User

Untitled

a guest
Dec 2nd, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. /*******************************************************************
  2. * An example of usisng the InstagramStats library to get
  3. * info on a given user
  4. *
  5. * Written by Brian Lough
  6. * https://www.youtube.com/channel/UCezJOfu7OtqGzd5xrP3q6WA
  7. *******************************************************************/
  8.  
  9. #include "InstagramStats.h"
  10. #include "Arduino.h"
  11. #include <Servo.h>
  12.  
  13. Servo servo1;
  14.  
  15. // ----------------------------
  16. // Standard Libraries - Already Installed if you have ESP32 set up
  17. // ----------------------------
  18.  
  19. #include <WiFi.h>
  20. #include <WiFiClientSecure.h>
  21.  
  22. //LED setup
  23. #define GREENPIN 38
  24. #define FADESPEED 5
  25.  
  26. //Servo
  27. static const int servoPin = 5;
  28. static const int potentiometerPin = 14;
  29.  
  30. int value;
  31.  
  32. // ----------------------------
  33. // Additional Libraries - each one of these will need to be installed.
  34. // ----------------------------
  35.  
  36. #include "JsonStreamingParser.h"
  37. // Used to parse the Json code within the library
  38. // Available on the library manager (Search for "Json Streamer Parser")
  39. // https://github.com/squix78/json-streaming-parser
  40.  
  41. //------- Replace the following! ------
  42. char ssid[] = "iPhone Maciek"; // your network SSID (name)
  43. char password[] = "o9h2gott"; // your network key
  44.  
  45. WiFiClientSecure client;
  46. InstagramStats instaStats(client);
  47.  
  48. unsigned long delayBetweenChecks = 20000; //mean time between api requests
  49. unsigned long whenDueToCheck = 0;
  50.  
  51. //Inputs
  52. String userName = "najadeostos"; // from their instagram url https://www.instagram.com/brian_lough/
  53.  
  54.  
  55. void setup() {
  56.  
  57. Serial.begin(115200);
  58. servo1.attach(servoPin);
  59.  
  60. // Attempt to connect to Wifi network:
  61. Serial.print("Connecting Wifi: ");
  62. Serial.println(ssid);
  63.  
  64. WiFi.mode(WIFI_STA);
  65. WiFi.begin(ssid, password);
  66. while (WiFi.status() != WL_CONNECTED) {
  67. Serial.print(".");
  68. delay(500);
  69. }
  70. Serial.println("");
  71. Serial.println("WiFi connected");
  72. Serial.println("IP address: ");
  73. IPAddress ip = WiFi.localIP();
  74. Serial.println(ip);
  75. }
  76.  
  77. void getInstagramStatsForUser() {
  78. Serial.println("Getting instagram user stats for " + userName );
  79. InstagramUserStats response = instaStats.getUserStats(userName);
  80. Serial.println("Response:");
  81. Serial.print("Number of followers: ");
  82. Serial.println(response.followedByCount);
  83. }
  84.  
  85. void loop() {
  86. unsigned long timeNow = millis();
  87. if ((timeNow > whenDueToCheck)) {
  88. getInstagramStatsForUser();
  89. whenDueToCheck = timeNow + delayBetweenChecks;
  90. }
  91. int value = read(response.followedByCount);
  92. int servoPosition = map(value, 166, 170, 0, 180);
  93. servo1.write(servoPosition);
  94. Serial.println(servoPosition);
  95. delay(20);
  96. }
  97. /* int value = (response.followedByCount);
  98. follows = map(value, 166, 170, 0, 255);
  99. analogWrite(GREENPIN, follows);
  100. delay(FADESPEED); */
  101.  
  102.  
  103.  
  104.  
  105. --------------------------------
  106.  
  107.  
  108.  
  109.  
  110. Arduino: 1.8.7 (Windows 10), Board: "WIFI_Kit_32, 80MHz, 921600"
  111.  
  112. C:\Users\tomak\Documents\Arduino\UserData_led_intensity_from_follows\UserData_led_intensity_from_follows.ino: In function 'void loop()':
  113.  
  114. UserData_led_intensity_from_follows:91:22: error: 'response' was not declared in this scope
  115.  
  116. int value = read(response.followedByCount);
  117.  
  118. ^
  119.  
  120. exit status 1
  121. 'response' was not declared in this scope
  122.  
  123. This report would have more information with
  124. "Show verbose output during compilation"
  125. option enabled in File -> Preferences.
Add Comment
Please, Sign In to add comment