7-segment and JSON

Dear all,

I setup json file from mysql and use arduinojson.h with my eth shield on UNO board everything is ok and my number(result) is showed in serial but i cabt achieve to send on 7-seg display any help about coding is very helpfull.
Regarding hardware UNO 3x resistance on digital pins wired well tested as counter

Thanks in advance

 #include <ArduinoJson.h>
#include <Ethernet.h>
#include <SPI.h>
#include "SevSeg.h"
SevSeg sevseg; //Instantiate a seven segment controller object

//#define MAX_NUMBER_STRINGS 12
//#define MAX_STRING_SIZE 8
//char testStrings[MAX_NUMBER_STRINGS][MAX_STRING_SIZE];

//#define PATTERN_CHANGE_TIME 1000
//unsigned long timer = millis() - PATTERN_CHANGE_TIME;
//byte testStringsPos = 0;

void setup() {
  // Initialize Serial port
  Serial.begin(9600);
  while (!Serial) continue;

  // Initialize Ethernet library
  byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
  if (!Ethernet.begin(mac)) {
    Serial.println(F("Failed to configure Ethernet"));
    return;
  }
  delay(1000);

  Serial.println(F("Povezujem..."));

  //Konekcija na server
  EthernetClient client;
  client.setTimeout(10000);
  if (!client.connect("myhost", 80)) {
    Serial.println(F("Connection failed"));
    return;
  }

  Serial.println(F("Konektovan!"));

  // Slanje HTTP request
  client.println(F("GET /arduino.php HTTP/1.0"));
  client.println(F("Host: myhost"));
  client.println(F("Connection: close"));
  if (client.println() == 0) {
    Serial.println(F("Failed to send request"));
    return;
  }

  // HTTP status
  char status[32] = {0};
  client.readBytesUntil('\r', status, sizeof(status));
  if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
    Serial.print(F("Unexpected response: "));
    Serial.println(status);
    return;
  }

  // preskoci HTTP headers
  char endOfHeaders[] = "\r\n\r\n";
  if (!client.find(endOfHeaders)) {
    Serial.println(F("Invalid response"));
    return;
  }

  // Allocate JsonBuffer
  // Use arduinojson.org/assistant to compute the capacity.
  const size_t capacity = JSON_OBJECT_SIZE(1) + JSON_ARRAY_SIZE(1) + 20;
  DynamicJsonBuffer jsonBuffer(capacity);
  //Ako ne prolazi dinamicki buffer moze se koristit static  //StaticJsonBuffer<200> jsonBuffer;

  // Parse JSON object
  JsonObject& root = jsonBuffer.parseObject(client);
  if (!root.success()) {
    Serial.println(F("Parsing failed!"));
    return;
  }
  
  //zamisao 1
  
  int fancount = root[String("fan_count")];
		if (fancount > 0) {
			Serial.print("Lajkeri: ");
			Serial.println(fancount);
 

//what next :D
 // Prikaz var-a fan_count i vrijednosti
 //  Serial.println(F("Lajkeri:"));
  // Serial.println(root["fan_count"].as<char*>());
  

  // Disconnect
  client.stop();
  
  
  byte numDigits = 3;
  byte digitPins[] = {10, 11, 12};
  byte segmentPins[] = {1, 2, 3, 4, 5, 6, 7};
  bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_ANODE; // See README.md for options
  bool updateWithDelays = false; // Default. Recommended
  bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
  bool disableDecPoint = true; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[]

  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros, disableDecPoint);
  sevseg.setBrightness(90);
  
  

  
}

void loop() {
  //sevseg.refreshDisplay(); // Must run repeatedly
}
  byte digitPins[] = {10, 11, 12};

Bad choice, these pins are used for SPI communication to the Ethernet Shield on the UNO. Use others, the analog pins (p.e. A0, A1, A2) seems to be a good choice in your case.

Ok i will try that but not familiar with analog how to read from them? Btw in serial from mysql i get number 147

If you able to help about coding i will respect that

Shadow86:
Ok i will try that but not familiar with analog how to read from them?

You will be using the analogue pins as digital pins.

I will update response from serial as image

I'm litlle confused regarding 7-seg on tft and std display i know how to achieve this but here i dont know im lost :confused:

I will update response from serial as image

Bad idea, this is text, so post it as text!
BTW: the code shown in that screen shot is not the same as you posted here.

Ok i will try that but not familiar with analog how to read from them?

Just connect it there and use this definition:

 byte digitPins[] = {A0, A1, A2};

Btw in serial from mysql i get number 147

And then? It's nice that your server provides that number.

Yes its the same code for above only part if statment is changed when trying to test something both approach work with server and get result on serial from mysql 147
Maybe is confused about //comments on diff language...

Btw i will try your solution and will keep this post updated

get result on serial from mysql 147

Is it possible that your server delivers exactly that value and no other one?

Hi guys still missing something...

Well my server get outpout from mysql row which is every 2min checked by server if number in row changed that must be updated on 7-seg.

My codding skill is not good i tried with analog pins and try to call function but not working...

If someone have time and want to parcipiate in finding solution can write here or pm me Im available if we find solution i will be thankfull to post here fixed code

Till then i hope someone will help to sort this out

Cheers

Post your current code and the adapted wiring diagram!