Arduino Nano bleibt hängen / stopped working

Hallo Zusammen.

Ich hoffe ihr könnt mir helfen. Ich habe mich, nach guten Erfahrungen mit einem Atmega32 mal an einen Arduino gewagt, da ich etwas sehr klein gebautes brauche.
Nun habe ich die Funktion von "serial.print" ausprobiert und musste nach dem Hochladen des Sketches feststellen, dass Arduino IDE nicht mehr reagierte.
Leider auch der Nano nicht mehr.
Und zu guter letzt kann ich nicht einmal mehr einen neuen Sketch hochladen.

Genutzt wird ein Arduino Nano 33 BLE mit Arduino IDE.

Da ich noch am Testen bin, wie ich etwas nutze, ist der Code natürlich voller Kommentare.


Hello everyone.

I hope you can help me. After good experiences with an Atmega32, I dared to use an Arduino because I needed something very small.
Now I have tried the function of "serial.print" and after uploading the sketch I discovered that the Arduino IDE no longer responded.
Unfortunately, the Nano no longer either.
Finally, I can't even upload a new sketch anymore.

An Arduino Nano 33 BLE with Arduino IDE is used.

Since I'm still testing how to use something, the code is of course full of comments.

/*
This is an example on how to use the 1.8" TFT 128x160 SPI ST7735 display using the Adafruit library.

ST7735 TFT SPI display pins for Arduino Uno/Nano:
 * LED =   3.3V
 * SCK =   13
 * SDA =   11
 * A0 =    8
 * RESET = 9
 * CS =    10
 * GND =   GND
 * VCC =   3.3V

Hardware SPI Pins:
 * Arduino Uno   SCK=13, SDA=11
 * Arduino Nano  SCK=13, SDA=11
 * Arduino Due   SCK=76, SDA=75
 * Arduino Mega  SCK=52, SDA=51

SPI pin names can be confusing. These are the alternative names for the SPI pins:
MOSI = DIN = R/W = SDO = DI = SI = MTSR = SDA = D1 = SDI
CS = CE = RS = SS
DC = A0 = DO = DOUT = SO = MRST
RESET = RST
SCLK = CLK = E = SCK = SCL = D0


Reference page for GFX Library: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-gfx-graphics-library.pdf


Color is expressed in 16 bit with Hexadecimal value.
To select a particular color, go here and copy the "Hexadecimal 16 bit color depth value":
https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html

Common colors:
 * BLACK    0x0000
 * BLUE     0x001F
 * RED      0xF800
 * GREEN    0x07E0
 * CYAN     0x07FF
 * MAGENTA  0xF81F
 * YELLOW   0xFFE0
 * WHITE    0xFFFF

A way to select a color is to write: "ST7735_BLACK", or "ST7735_BLUE", etc.
Or just write the code for the color. Either way, it works.


List of custom fonts: https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts

Note about custom font:
 * Text background color is not supported for custom fonts. For these reason you would need to draw a filled 
   rectangle before drawing the text. But this would cause the text to flicker, so I don't recommend using custom fonts
   for components that refresh continuously.
 * Using custom fonts slows down the arduino loop, so the refresh rate is lesser than using the standard font.


Sketch made by: InterlinkKnight
Last modification: 01/11/2018
*/


#include <Adafruit_GFX.h>  // Include core graphics library
#include <Adafruit_ST7735.h>  // Include Adafruit_ST7735 library to drive the display


// Declare pins for the display:
#define TFT_CS     10
#define TFT_RST    9  // You can also connect this to the Arduino reset in which case, set this #define pin to -1!
#define TFT_DC     8
// The rest of the pins are pre-selected as the default hardware SPI for Arduino Uno (SCK = 13 and SDA = 11)

//Declare Pins für RGB-LED
 #define RED 22      
 #define GREEN 23    
 #define BLUE 24


// Create display:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

//#include <Fonts/FreeSerif18pt7b.h>  // Add a custom font




uint16_t width(128);   //Breite
uint16_t height(160);  //Hoehe


int Variable1;  // Create a variable to have something dynamic to show on the display
int Variable2;
int Variable3;
int Button_Counter;


// constants won't change. They're used here to set pin numbers:
const byte Pin_Button = 7;     // the number of the pushbutton pin
const byte Pin_Signal = 2;     // the number of the pushbutton pin

// variables will change:
int State_Button = 0;         // variable for reading the pushbutton status
int State_Signal = 0;
int State_LED = 0;

long Timer1 = 0;
long Timeout1 = 500;



/*
 Frequenzzähler
 Gibt die Frequenz des Spannungsignals an Pin 7 aus 
*/
unsigned long T;          //Periodendauer in us
unsigned long T2;          //Periodendauer in s
double f;





void setup()  // Start of setup
{
  Serial.begin(9600);
  
  // initialize the LED pin as an output:
  //pinMode(LED_BUILTIN, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(Pin_Button, INPUT);
  pinMode(Pin_Signal, INPUT);
  
  
  // Display setup:

  // Use this initializer if you're using a 1.8" TFT
  tft.initR(INITR_BLACKTAB);  // Initialize a ST7735S chip, black tab

  tft.fillScreen(ST7735_BLACK);  // Fill screen with black

  tft.setRotation(0);  // Set orientation of the display. Values are from 0 to 3. If not declared, orientation would be 0,
                         // which is portrait mode.

  tft.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
                           // To override this behavior (so text will run off the right side of the display - useful for
                           // scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored
                           // with setTextWrap(true).




  // We are going to print on the display everything that is static on the setup, to leave the loop free for dynamic elements:

  
  tft.setCursor(0, 43);  // Set position (x,y)
  tft.setTextColor(ST7735_WHITE);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println("Verbrauch");  // Print a text or value

  
  tft.setCursor(99, 63);  // Set position (x,y)
  tft.setTextColor(ST7735_WHITE);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println("l");  // Print a text or value

  //Draw line:
  tft.drawLine(83, 80, 124, 80, ST7735_WHITE);  // Draw line (x0,y0,x1,y1,color)

  tft.setCursor(87, 83);  // Set position (x,y)
  tft.setTextColor(ST7735_WHITE);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println("min");  // Print a text or value


  tft.setCursor(0, 0);  // Set position (x,y)
  tft.setTextColor(ST7735_WHITE);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println("Reichweite");  // Print a text or value

  //Draw line: (Senkrecht)
  tft.drawLine(103, 63, 103, 97, ST7735_WHITE);  // Draw line (x0,y0,x1,y1,color)
  
}  // End of setup







void loop()  // Start of loop
{
//  if (millis() > Timeout1 + Timer1 ) {
//    Timer1 = millis();
//
//    if (State_LED == LOW)
//    {
//      State_LED = HIGH;
//      digitalWrite(GREEN, HIGH);
//    }
//    else
//    {
//      State_LED = LOW;
//      digitalWrite(GREEN, LOW);
//    }
//  }
  
  
  T = pulseIn(Pin_Signal, HIGH) + pulseIn(Pin_Signal, LOW);
  if (T==0)
  {
    Serial.println("Timeout.");
  }
  else 
  {
    f=1/(double)T;          // f=1/T                 
  }
  T2 = T / 1000000;
  
  Serial.print(f*1e6);      //Ausgabe in Hertz
  Serial.print(" Hz;     ");
  Serial.print(T/1000);          //Ausgabe in µs
  Serial.print(" ms;     ");
  Serial.print(1/T2, 3);          //Ausgabe in ml/s
  Serial.print((1/(T2/10500))/1000, 3);          //Ausgabe in ml/s
  Serial.print(" ml/s;     ");
  Serial.print((1/(T/1000/105))*600, 3);          //Ausgabe in l/min
  Serial.println(" l/min");

  
  
  State_Signal = digitalRead(Pin_Signal);

  if (State_Signal == LOW)
  {
    // turn LED on:
    digitalWrite(BLUE, HIGH);
    Serial.println("Signal an");
  }
  else
  {
    // turn LED off:
    digitalWrite(BLUE, LOW);
    //Serial.println("Signal aus");
  }

  
  State_Button = digitalRead(Pin_Button);

  if (State_Button == LOW)
  {
    // turn LED on:
    digitalWrite(RED, LOW);

    Button_Counter++;
  }
  else
  {
    // turn LED off:
    digitalWrite(RED, HIGH);
  }

  if (Button_Counter == 0)
  {
    Variable1 = 8;
    Variable2 = 1;
  }
  else if (Button_Counter == 1)
  {
    Variable1 = 88;
    Variable2 = 2;
  }
  else if (Button_Counter == 2)
  {
    Variable1 = 888;
    Variable2 = 3;
  }
  else if (Button_Counter == 3)
  {
    Variable1 = 8888;
    Variable2 = 4;
  }
  else if (Button_Counter == 4)
  {
    Variable1 = 888;
    Variable2 = 5;
  }
  else if (Button_Counter == 5)
  {
    Variable1 = 88;
    Variable2 = 6;
  }
  else
  {
    Button_Counter = 0;
  }
  
  
  if(Variable3 > 150)  // If Variable1 is greater than 150
  {
    Variable3 = 0;  // Set Variable1 to 0
  }
  else
  {
    Variable3++;  // Increase variable by 1
  }





  // We are going to print on the display everything that is dynamic on the loop, to refresh continuously:

  // Write to the display the Variable1 with right text alignment:
  if (Variable1 <= 9)
  {
    tft.setCursor(63, 70);  // Set position (x,y)
    tft.fillRect(9, 70, 51, 21, ST7735_RED);  // Draw filled rectangle (x,y,width,height,color)
  }
  else if (Variable1 <= 99)
  {
    tft.setCursor(45, 70);  // Set position (x,y)
    tft.fillRect(9, 70, 33, 21, ST7735_GREEN);  // Draw filled rectangle (x,y,width,height,color)
  }
  else if (Variable1 <= 999)
  {
    tft.setCursor(27, 70);  // Set position (x,y)
    tft.fillRect(9, 70, 15, 21, ST7735_BLUE);  // Draw filled rectangle (x,y,width,height,color)
  }
  else if (Variable1 <= 9999)
  {
    tft.setCursor(9, 70);  // Set position (x,y)
  }
  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(3);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println(Variable1);  // Print a text or value

  tft.setCursor(83, 127);  // Set position (x,y)
  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println(Variable2);  // Print a text or value

  tft.setCursor(13, 107);  // Set position (x,y)
  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println(Variable3);  // Print a text or value
  
}  // End of loop



// Draw rectangle:
  //tft.drawRect(0, 60, 60, 30, ST7735_CYAN);  // Draw rectangle (x,y,width,height,color)
                                             // It draws from the location to down-right
                                             
  // Draw rounded rectangle:
  //tft.drawRoundRect(68, 60, 60, 30, 10, ST7735_CYAN);  // Draw rounded rectangle (x,y,width,height,radius,color)
                                                       // It draws from the location to down-right


  // Draw triangle:
  //tft.drawTriangle(60,120,    70,94,    80,120, ST7735_YELLOW);  // Draw triangle (x0,y0,x1,y1,x2,y2,color)


  // Draw filled triangle:
  //tft.fillTriangle(100,120,    110,94,    120,120, ST7735_CYAN);  // Draw filled triangle (x0,y0,x1,y1,x2,y2,color)


  // Draw line:
  //tft.drawLine(0, 125, 127, 125, ST7735_CYAN);  // Draw line (x0,y0,x1,y1,color)
  

  //  Draw circle:
  //tft.drawCircle(15, 144, 14, ST7735_GREEN);  //  Draw circle (x,y,radius,color)


  // Draw a filled circle:
  //tft.fillCircle(60, 144, 14, ST7735_BLUE);  // Draw circle (x,y,radius,color)


  // Draw rounded rectangle and fill:
  //tft.fillRoundRect(88, 130, 40, 27, 5, 0xF81B);  // Draw rounded filled rectangle (x,y,width,height,color)

Nun hatte ich schon versucht einen leeren Sketch hochzuladen.


Now I had already tried to upload an empty sketch.

(...)
Der Sketch verwendet 83440 Bytes (8%) des Programmspeicherplatzes. Das Maximum sind 983040 Bytes.
Globale Variablen verwenden 43920 Bytes (16%) des dynamischen Speichers, 218224 Bytes für lokale Variablen verbleiben. Das Maximum sind 262144 Bytes.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM3
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
PORTS {COM3, } / {COM3, } => {}
Uploading using selected port: COM3
C:\Users\Daniel\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino2/bossac.exe -d --port=COM3 -U -i -e -w C:\Users\Daniel\AppData\Local\Temp\arduino_build_909278/sketch_jul27a.ino.bin -R 
Beim Hochladen des Sketches ist ein Fehler aufgetreten
processing.app.SerialException: Fehler beim Öffnen des seriellen Ports "COM3".
	at processing.app.Serial.<init>(Serial.java:152)
	at processing.app.Serial.<init>(Serial.java:82)
	at processing.app.SerialMonitor$2.<init>(SerialMonitor.java:132)
	at processing.app.SerialMonitor.open(SerialMonitor.java:132)
	at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
	at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2120)
	at processing.app.Editor.access$1300(Editor.java:117)
	at processing.app.Editor$UploadHandler.run(Editor.java:2089)
	at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM3; Method name - openPort(); Exception type - Port busy.
	at jssc.SerialPort.openPort(SerialPort.java:164)
	at processing.app.Serial.<init>(Serial.java:141)
	... 8 more
Fehler beim Öffnen des seriellen Ports "COM3".

Und nun stehe ich da. Kann ich irgendwie denn Sketch löschen. Oder liegt gar ein ganz anderes Problem vor?
Die Probleme starteten mit diesen Zeilen:

 Serial.print(1/T2, 3);          //Ausgabe in ml/s
  Serial.print((1/(T2/10500))/1000, 3);          //Ausgabe in ml/s
  Serial.print(" ml/s;     ");
  Serial.print((1/(T/1000/105))*600, 3);          //Ausgabe in l/min
  Serial.println(" l/min");

And now I stand there. Can I somehow delete the sketch. Or is there a completely different problem?
The problems started with these lines:

 Serial.print(1/T2, 3);          //Ausgabe in ml/s
  Serial.print((1/(T2/10500))/1000, 3);          //Ausgabe in ml/s
  Serial.print(" ml/s;     ");
  Serial.print((1/(T/1000/105))*600, 3);          //Ausgabe in l/min
  Serial.println(" l/min");

Hallo,
ich würde da mal ganz systematisch vorgehen
PC neu booten
IDE starten
richtige Schnittstelle einstellen
Blink Sketch auf den Nano
Fehler auswerten

Heinz

Danke für deine Antwort.
Der Fehler-Code des IDE ist leider von heute.
Nachdem ich den PC hochgefahren, IDE gestartet und einen leeren Skrech hochladen wollte.
Port war wie immer Com 3.

Der Arduino wird vom PC erkannt, das angeschlossene Display zeigt auch die Schrift aus dem Setup, aber bleibt dann stehen.

Den Seriellen Monitor bekomme ich auch nach 5 Minuten warten auf. Darin stehen allerdings dann keine Daten.

Ich bin bisher ziemlich ratlos.

Gibt es eine Möglichkeit, wie bei einem Atmega über MISO und MOSI zu löschen?
Oder würde dies auch zu einem Zugriffsfehler führen?

Ein Arduino NANO ist ganz etwas anderes als ein Arduino Nano 33 BLE .

Bist Du sicher, daß die Bibliothek mit dem Controller des Arduino Nano 33 BLE funktioniert?.
In der Aufstellung im Kommentar wird der 33 BLE nicht genannt.

Ich glaube im deutschen Teil des Forums können die User schon genügend Deutsch, daß Du keine englische Übersetzung machen mußt.

Grüße Uwe

Danke für die Antwort.

Die englische Übersetzung habe ich daher eongestellt, da ich im internationalen Berech das Thema eingestellt habe. Leider wurde es in den deutschen Bereich verschoben.

Die Auflistung entstammt eines Kollegen, der den Code geschrieben hat. Ich habe ihn genutzt und erfolgreiche den Serial.print, sowie die Ausgabe auf den TFT zu bringen.
Bist vorgestern, als ich an serial.print arbeitete, um zu schauen, wie ich die Darstellung hinbekomme und den gewünschten Wert erhalten.
Direkt nach dem Hochladen wurde der BLE unerreichbar.
Was vorher lief wurde aus irgendeinem Grund durch den print-Satz aufgehoben.

Und nun stehe ich da.
Da er erreichtbar ist, ist es kein Defekt. Aber eine Unbeschreibbarkeit setzt es dem gleich :confused:

Hat Dein Kollege den Sketch mit einem Arduino Nano 33 BLE ausprobiert oder mit einem anderen Arduino?
Grüße Uwe

Irgendwie widerspricht sich das.

So wie ich deinen Sketch lese, ist der für einen "normalen" Arduino Nano geschrieben, aber nicht für den BLE.

Wurde für einen Arduino Nano geschrieben: YouTube-Video der Quelle

/*
This is an example on how to use the 1.8" TFT 128x160 SPI ST7735 display using the Adafruit library.

ST7735 TFT SPI display pins for Arduino Uno/Nano:
 * LED =   3.3V
 * SCK =   13
 * SDA =   11
 * A0 =    8
 * RESET = 9
 * CS =    10
 * GND =   GND
 * VCC =   5V

Another version marked as KMR-1.8 SPI:
This version only supports 3.3V logic so put a level shifter for all I/O pins, or a 2.2k resistor between
the display and arduino, and a 3.3k resistor to ground to create a simple voltage divider to produce a 3V output.
 * LED- =  GND
 * LED+ =  15Ω resistor to 5V
 * CS =    10
 * SCL =   13
 * SDA =   11
 * A0  =   8
 * RESET = 9
 * VCC =   5V or 3.3V (the display has it's own 3.3V regulator)
 * GND =   GND

Hardware SPI Pins:
 * Arduino Uno   SCK=13, SDA=11
 * Arduino Nano  SCK=13, SDA=11
 * Arduino Due   SCK=76, SDA=75
 * Arduino Mega  SCK=52, SDA=51

SPI pin names can be confusing. These are the alternative names for the SPI pins:
MOSI = DIN = R/W = SDO = DI = SI = MTSR = SDA = D1 = SDI
CS = CE = RS = SS
DC = A0 = DO = DOUT = SO = MRST
RESET = RST
SCLK = CLK = E = SCK = SCL = D0


Libraries needed:
https://github.com/adafruit/Adafruit-ST7735-Library
https://github.com/adafruit/Adafruit-GFX-Library


Reference page for GFX Library: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-gfx-graphics-library.pdf


Color is expressed in 16 bit with Hexadecimal value.
To select a particular color, go here and copy the "Hexadecimal 16 bit color depth value":
https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html

Common colors:
 * BLACK    0x0000
 * BLUE     0x001F
 * RED      0xF800
 * GREEN    0x07E0
 * CYAN     0x07FF
 * MAGENTA  0xF81F
 * YELLOW   0xFFE0
 * WHITE    0xFFFF

A way to select a color is to write: "ST7735_BLACK", or "ST7735_BLUE", etc.
Or just write the code for the color. Either way, it works.


List of custom fonts: https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts

Note about custom font:
 * Text background color is not supported for custom fonts. For these reason you would need to draw a filled 
   rectangle before drawing the text. But this would cause the text to flicker, so I don't recommend using custom fonts
   for components that refresh continuously.
 * Using custom fonts slows down the arduino loop, so the refresh rate is lesser than using the standard font.


Sketch made by: InterlinkKnight
Last modification: 01/11/2018
*/



#include <Adafruit_GFX.h>  // Include core graphics library
#include <Adafruit_ST7735.h>  // Include Adafruit_ST7735 library to drive the display


// Declare pins for the display:
#define TFT_CS     10
#define TFT_RST    9  // You can also connect this to the Arduino reset in which case, set this #define pin to -1!
#define TFT_DC     8
// The rest of the pins are pre-selected as the default hardware SPI for Arduino Uno (SCK = 13 and SDA = 11)


// Create display:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);



#include <Fonts/FreeSerif18pt7b.h>  // Add a custom font





int Variable1;  // Create a variable to have something dynamic to show on the display






void setup()  // Start of setup
{

  // Display setup:

  // Use this initializer if you're using a 1.8" TFT
  tft.initR(INITR_BLACKTAB);  // Initialize a ST7735S chip, black tab

  tft.fillScreen(ST7735_BLACK);  // Fill screen with black

  //tft.setRotation(0);  // Set orientation of the display. Values are from 0 to 3. If not declared, orientation would be 0,
                         // which is portrait mode.

  tft.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
                           // To override this behavior (so text will run off the right side of the display - useful for
                           // scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored
                           // with setTextWrap(true).




  // We are going to print on the display everything that is static on the setup, to leave the loop free for dynamic elements:

  // Write to the display the text "Hello":
  tft.setCursor(0, 0);  // Set position (x,y)
  tft.setTextColor(ST7735_WHITE);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(3);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println("Hello");  // Print a text or value

  
  
  // Start using a custom font:
  tft.setFont(&FreeSerif18pt7b);  // Set a custom font
  tft.setTextSize(0);  // Set text size. We are using custom font so you should always set text size as 0

  // Write to the display the text "World":
  tft.setCursor(0, 50);  // Set position (x,y)
  tft.setTextColor(ST7735_RED);  // Set color of text. We are using custom font so there is no background color supported
  tft.println("World!");  // Print a text or value

  // Stop using a custom font:
  tft.setFont();  // Reset to standard font, to stop using any custom font previously set




  // Draw rectangle:
  tft.drawRect(0, 60, 60, 30, ST7735_CYAN);  // Draw rectangle (x,y,width,height,color)
                                             // It draws from the location to down-right
                                             
  // Draw rounded rectangle:
  tft.drawRoundRect(68, 60, 60, 30, 10, ST7735_CYAN);  // Draw rounded rectangle (x,y,width,height,radius,color)
                                                       // It draws from the location to down-right


  // Draw triangle:
  tft.drawTriangle(60,120,    70,94,    80,120, ST7735_YELLOW);  // Draw triangle (x0,y0,x1,y1,x2,y2,color)


  // Draw filled triangle:
  tft.fillTriangle(100,120,    110,94,    120,120, ST7735_CYAN);  // Draw filled triangle (x0,y0,x1,y1,x2,y2,color)


  // Draw line:
  tft.drawLine(0, 125, 127, 125, ST7735_CYAN);  // Draw line (x0,y0,x1,y1,color)
  

  //  Draw circle:
  tft.drawCircle(15, 144, 14, ST7735_GREEN);  //  Draw circle (x,y,radius,color)


  // Draw a filled circle:
  tft.fillCircle(60, 144, 14, ST7735_BLUE);  // Draw circle (x,y,radius,color)


  // Draw rounded rectangle and fill:
  tft.fillRoundRect(88, 130, 40, 27, 5, 0xF81B);  // Draw rounded filled rectangle (x,y,width,height,color)
  
}  // End of setup







void loop()  // Start of loop
{

  Variable1++;  // Increase variable by 1
  if(Variable1 > 150)  // If Variable1 is greater than 150
  {
    Variable1 = 0;  // Set Variable1 to 0
  }


  // Convert Variable1 into a string, so we can change the text alignment to the right:
  // It can be also used to add or remove decimal numbers.
  char string[10];  // Create a character array of 10 characters
  // Convert float to a string:
  dtostrf(Variable1, 3, 0, string);  // (<variable>,<amount of digits we are going to use>,<amount of decimal digits>,<string name>)







  // We are going to print on the display everything that is dynamic on the loop, to refresh continuously:

  // Write to the display the Variable1 with left text alignment:
  tft.setCursor(13, 67);  // Set position (x,y)
  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println(Variable1);  // Print a text or value
  
  // There is a problem when we go, for example, from 100 to 99 because it doesn't automatically write a background on
  // the last digit we are not longer refreshing. We need to check how many digits are and fill the space remaining.
  if(Variable1 < 10)  // If Variable1 is less than 10...
  {
    // Fill the other digit with background color:
    tft.fillRect(23, 67, 12, 18, ST7735_BLACK);  // Draw filled rectangle (x,y,width,height,color)
  }
  if(Variable1 < 100)  // If Variable1 is less than 100...
  {
    // Fill the other digit with background color:
    tft.fillRect(36, 67, 12, 18, ST7735_BLACK);  // Draw filled rectangle (x,y,width,height,color)
  }




  // Write to the display the string with right text alignment:
  tft.setCursor(81, 67);  // Set position (x,y)
  tft.setTextColor(ST7735_GREEN, ST7735_BLACK);  // Set color of text. First is the color of text and after is color of background
  tft.setTextSize(2);  // Set text size. Goes from 0 (the smallest) to 20 (very big)
  tft.println(string);  // Print a text or value








  // We are going to write the Variable1 with a custom text, so you can see the issues:
  
  // Draw a black square in the background to "clear" the previous text:
  // This is because we are going to use a custom font, and that doesn't support brackground color.
  // We are basically printing our own background. This will cause flickering, though.
  tft.fillRect(0, 90, 55, 34, ST7735_BLACK);  // Draw filled rectangle (x,y,width,height,color)




  // Start using a custom font:
  tft.setFont(&FreeSerif18pt7b);  // Set a custom font
  tft.setTextSize(0);  // Set text size. We are using custom font so you should always set text size as 0

  // Write to the display the Variable1:
  tft.setCursor(0, 120);  // Set position (x,y)
  tft.setTextColor(ST7735_MAGENTA);  // Set color of text. We are using custom font so there is no background color supported
  tft.println(Variable1);  // Print a text or value

  // Stop using a custom font:
  tft.setFont();  // Reset to standard font, to stop using any custom font previously set





}  // End of loop

Irgendwie widerspricht sich das.

Doof ausgedrückt. Entschuldige.
Er bleibt erkannt, kann aber nicht beschrieben werden.

Ich habe grade nochmal versucht das Beispiel Blink hochzuladen.
Leider ohne Erfolg.
Folgendes kommt immer nach dem Kompilieren:

Der Sketch verwendet 83440 Bytes (8%) des Programmspeicherplatzes. Das Maximum sind 983040 Bytes.
Globale Variablen verwenden 43920 Bytes (16%) des dynamischen Speichers, 218224 Bytes für lokale Variablen verbleiben. Das Maximum sind 262144 Bytes.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM3

Und dann kann ich solange warten bis er abbricht :slightly_frowning_face:

Ich kenne den Nano BLE selbst nicht. Der ist auch nicht sehr verbreitet.

Versuche mal nach dem Kompilieren den Resetbutton zu drücken.

Dann kommt leider folgende Fehlermeldung:

Arduino: 1.8.15 (Windows 10), Board: "Arduino Nano 33 BLE"

(...)

Der Sketch verwendet 83440 Bytes (8%) des Programmspeicherplatzes. Das Maximum sind 983040 Bytes.

Globale Variablen verwenden 43920 Bytes (16%) des dynamischen Speichers, 218224 Bytes für lokale Variablen verbleiben. Das Maximum sind 262144 Bytes.

Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM3

PORTS {COM3, } / {COM4, } => {COM4, }

Found upload port: COM4

C:\Users\Daniel\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino2/bossac.exe -d --port=COM4 -U -i -e -w C:\Users\Daniel\AppData\Local\Temp\arduino_build_460054/Blink.ino.bin -R 

No device found on COM4

Beim Hochladen des Sketches ist ein Fehler aufgetreten

Aus einem mir unerfindlichen Grund wechselt die IDE nach dem Hochladen immer auf Com4. Stört mich ein wenig.

Aber leider auch immer, wenn man Reset klickt. Dadurch auch, wie hier.
Habe auch shcon probiert gedrückt zu halten und in dem Moment, oder etwas früher, wenn das Kompilieren fertig ist, loszulassen. Alles ohne Erfolg

Hallo,

dann prüfe doch erst mal ob Du den Blink Sketch auf einen normalen Nano/ Uno drauf bekommst. Dann hättest Du schon mal die Aussage das die IDE Installation wahrscheinlich ok ist.

ich kenne den Nano BLE auch nicht

Das ist ok, da Hauptprogramm und Bootloader abwechselnd laufen und jeweils ihren eigenen COM Port haben.
Das machen alle Arduinos mit nativen USB Schnittstellen so. Diese aktivieren über die 1200 Baud Umschaltung den Bootloader.

So auch der Micro, Leonardo, die SAMD Dinger

1 Like

Wen er USB3 benutzt Dan stimmt es oder?
ich klemme alles auf direkten USB2 Port.
manche USB3 ports unter Win10 haben sein "eignes Leben verhalten " je nach dem was am PC Board gelötet wurde

1 Like

Hast Du das schcon durchgelesen?
https://www.arduino.cc/en/Guide/NANO33BLE

1 Like

Ich bin euch für eure Hilfe dankbar. Aber versteht mich nicht falsch.
Das oben gepostete Programm lief schon mehrere Tage ohne Probleme. Ich habe bis vor kurzem den BLE schon 20 mal beschrieben.
Ich habe damals mit Blink angefangen, dann mal mit der RGB-LED gespielt und dann angefangen das TFT zu programmieren. Habe dort neue Texte und Variablen zum Test eingefügt.
Dann ein paar Zeilen mit Serial.print beschrieben, um mal zu schauen, wie das klappt.

Und dann vor kurzem die Zeilen oben - von denen ich ausgehe den Fehler produzieren - programmiert und hochgeladen. Und seit dem, kann ich dem Arduino kein Skretch mehr schicken, keine Infos über den Seriellen Monitor.

Nur der Text aus dem Setup, der auf das TFT geschrieben wird, sind noch zu lesen.

Meine Erfahrung mit Atmega zahlt sich leider nur soweit aus, bis der Arduino nicht mehr will.
Ich weiß leider nicht, ob es einen Modus gibt, in dem der Arduino das Programm nicht startet.

Bin mittlerweile schon auf USB2 gegangen. Hat aber leider auch nicht viel verändert :sweat_smile:

Was meinst du mir "direkten USB2"?

Du hast mich auf eine Idee gebracht!
Vielen lieben Dank.

Ich habe mal einen ganz anderen Port (im PC Frontpanel) genommen. Zufälliger Weise COM4.
Habe IDE gestartet und plötzlich blinkte die gelbe LED und wartete auf den Skretch.
Also Blink installiert. Und plötzlich ging es wieder.

Was für ein Glück. Vielen Dank Leute. Was auch immer das war.

Jetzt kommen erstmal die Serial.prints raus.

 T = pulseIn(Pin_Signal, HIGH) + pulseIn(Pin_Signal, LOW);

Macht den Arduino extrem langsam. Das bin ich so nicht gewöhnt.
Geht eigentlich auch die Implementierung von normalen Timer_ISR, wie bei einem Atmega.
Habe dazu leider noch nichts gefunden.

pulseIn ist blockierend, wartet ggf. auf den Timeout.

1 Like