Плата зависает при работе
- Войдите на сайт для отправки комментариев
Ср, 09/05/2018 - 16:59
При написани скетча для управления лед-лентой дистанционо при использовании ethernet shield+arduinio uno+HMI Virtuino ардуино зависает может кто помочь?
#include "VirtuinoEthernet_WebServer.h" // Neccesary virtuino library for ethernet shield
#include <dht.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define dht_apin A0 // Analog Pin sensor is connected to
#define PIN 3
#define NUMPIXELS 15
dht DHT;
int vikl=0;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // Set the ethernet shield mac address.
IPAddress ip(192, 168, 0, 150); // Set the ethernet shield ip address. Check your gateway ip address first
VirtuinoEthernet_WebServer virtuino(8000); // default port=8000
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 250; // delay
//================================================================== setup
void setup()
{
virtuino.DEBUG=true; // set this value TRUE to enable the serial monitor status
Serial.begin(9600); // Enable this line only if DEBUG=true
Ethernet.begin(mac, ip);
virtuino.password="1234"; // Set a password to your web server for more protection
// avoid special characters like ! $ = @ # % & * on your password. Use only numbers or text characters
//------ enter your setup code below
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
pinMode(6,OUTPUT); // Connect a Led to pin 6
// Don't use pins 10,11,12,13 in your code. They used by Ethernet Shield
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 1116000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
//================================================================== loop
////void readTemperatures(){
// Serial.println("Read sensors' values...");
// float temperature = DHT.readTemperature();
// float humidity = DHT.readHumidity();
// if (isnan(temperature) || isnan(humidity)) {
// Serial.println("Failed to read from DHT");
// }
// else {
// Serial.println("Temp="+String(temperature)+" *C");
// Serial.println("Humidity="+String(humidity)+" %");
// virtuino.vMemoryWrite(0,temperature); // write temperature 1 to virtual pin V0. On Virtuino panel add a value display or an analog instrument to pin V0
// virtuino.vMemoryWrite(1,humidity); // write temperature 1 to virtual pin V1. On Virtuino panel add a value display or an analog instrument to pin V1
// }
//
//}
void loop(){
virtuino.run(); // necessary command to communicate with Virtuino android app
//------ enter your loop code below here
//------ avoid to use delay() function in your code. Use the command virtuino.vDelay() instead of delay()
// your code .....
//Start of Program
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");
delay(2000);//Wait 5 seconds before accessing sensor again.
virtuino.vMemoryWrite(0,DHT.temperature); // write temperature 1 to virtual pin V0. On Virtuino panel add a value display or an analog instrument to pin V0
virtuino.vMemoryWrite(1,DHT.humidity); // write temperature 1 to virtual pin V1. On Virtuino panel add a value display or an analog instrument to pin V1
//Fastest should be once every two seconds.
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
//virtuino.vMemoryWrite(3,pixels.Color(10,10,0));
//pixels.setPixelColor(i, pixels.Color(10,10,0)); // Moderately bright green color.
//pixels.show(); // This sends the updated pixel color to the hardware.
int vkl=virtuino.vMemoryRead(3); //прием параметров с virtuino 1 или 0
if (vkl=0){
pixels.setPixelColor(i, pixels.Color(0,0,0));
else {
pixels.setPixelColor(i, pixels.Color(10,0,50));}
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}}
// end loop()
//----- end of your coder
а что пишет при компиляции - сколько занимает код и сколько данные
а что пишет при компиляции - сколько занимает код и сколько данные
70% памяти проблема из-за дилэя была