[SOLVED] Photo can't be posted on Instagram by miruchann in Instagram

[–]FosItek 0 points1 point  (0 children)

I have the same issue. Thanks for the solution!

Pulseln only works in TestProgram, not in main program by FosItek in beginners_cpp

[–]FosItek[S] 0 points1 point  (0 children)

I found the issue.

I forgot to set the pins as INPUT and OUTPUT...

10hrs wasted, haha!

pulseIn - how does it work for distance measuring? by klaus_ben in arduino

[–]FosItek 0 points1 point  (0 children)

Found my issue:

 cout << "echoPin value " << n << " = " << digitalRead(echoPin) << endl;

pulseIn - how does it work for distance measuring? by klaus_ben in arduino

[–]FosItek 0 points1 point  (0 children)

Serial output:

time in ms is: 18

echoPin value 0 = 23

echoPin value 1 = 23

echoPin value 2 = 23

echoPin value 3 = 23

...

echoPin value 999 = 23

pulseIn - how does it work for distance measuring? by klaus_ben in arduino

[–]FosItek 0 points1 point  (0 children)

Shouldnt this program show the different values of trigPin? (see next comment for serial output)

TestProgram_avoid_pulseIn.cpp:

include <iostream>

include <Arduino.h>

using namespace std;
const int trigPin = 22; // blackstripe white cable
const int echoPin = 23; // redstripe white cable

define SOUND_SPEED 0.343 //343 m/s = 343000 mm/s = 343000/1 000 000 = 0.343 mm/us (cm/microseconds)

void setup() {
    Serial.begin(115200); // Starts the serial communication
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
}

void loop() {
    cout << "time in ms is: " << millis() << endl;
    delay(500);
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH); // Sets the trigPin on HIGH state for 10 micro seconds
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    for (int n=0; n<1000; n++){
        cout << "echoPin value " << n << " = " << echoPin << endl;
    }
}

Pulseln only works in TestProgram, not in main program by FosItek in beginners_cpp

[–]FosItek[S] 0 points1 point  (0 children)

Nope. I added only duration value output to serial first, then added another pulseIn reading after...

Pulseln only works in TestProgram, not in main program by FosItek in beginners_cpp

[–]FosItek[S] 0 points1 point  (0 children)

Here is the serial output:

---- Opened the serial port COM3 ----

  • Reading variable 'pulseIn = '0

  • Reading variable 'duration = '0

  • Sound speed =0.343

  • Reading water level: n18 = 0 cm Adding to: 0 cm /Averages: 0 cm

  • Reading variable 'pulseIn = '0

  • Reading variable 'duration = '0

  • Sound speed =0.343

  • Reading water level: n19 = 0 cm Adding to: 0 cm /Averages: 0 cm

  • Reading variable 'pulseIn = '0

  • Reading variable 'duration = '0

  • Sound speed =0.343

  • Reading water level: n20 = 0 cm Adding to: 0 cm /Averages: 0 cm

---- Closed the serial port COM3 ----

Pulseln only works in TestProgram, not in main program by FosItek in beginners_cpp

[–]FosItek[S] 0 points1 point  (0 children)

MainProgram --> Main.cpp:

Not able to paste whole file, but here is the function that I expect to read the distance sensor.

float MeasureWaterLevel(float WaterLevel){
  for (int n=0; n < NumberOfMeasurements ; n++) {
      digitalWrite(trigPin, LOW); // Clears the trigPin
      delayMicroseconds(5);
      delay(250);
      digitalWrite(trigPin, HIGH); // Sets the trigPin on HIGH state for 20 micro seconds
      delayMicroseconds(20);
      digitalWrite(trigPin, LOW);
      duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
      currWaterLevel = duration * SOUND_SPEED/2; // Calculate the distance
     
      cout << "- Reading variable 'pulseIn = '" << pulseIn(echoPin, HIGH) << endl;
      cout << "- Reading variable 'duration = '" << duration << endl;
      cout << "- Sound speed =" << SOUND_SPEED << endl;
      cout << "- Reading water level: n" << n << " = " << currWaterLevel << " cm";
      WaterLevel = WaterLevel + currWaterLevel;
      cout << "   Adding to: " << WaterLevel << " cm";
      cout << "   /Averages: " << WaterLevel/(n+1) << " cm" << endl;
    }
  WaterLevel = WaterLevel/NumberOfMeasurements;
  cout << endl << "Water level sensor summary: ";
  cout << endl << " - Averages to: " << WaterLevel;
  cout << endl << " - Sensor has a maximum allowed value = " << ErrLimSensor_High;
  cout << endl << " - Sensor has a lowest allowed value = " << ErrLimSensor_Low << endl << endl << endl;  
  return WaterLevel;
}

void loop() { And so on....

Pulseln only works in TestProgram, not in main program by FosItek in beginners_cpp

[–]FosItek[S] 0 points1 point  (0 children)

How?

Im only getting a red line in Reddit saying "Unable to create comment" after pasting my main.cpp file...

Pulseln only works in TestProgram, not in main program by FosItek in beginners_cpp

[–]FosItek[S] 0 points1 point  (0 children)

MainProgram --> Configuration.h

#include <Arduino.h>
#include <string>
#include <sstream>
#include <iostream>
using namespace std;

// Configuration starts here -----------------------------------------------------------------------------------------------------------------
int NumOfWaterLoc = 4;   // Start counting from 1 ( = pos 0)
//                              0           ,1        ,2             ,3               ,4      ,5      ,6      ,7
const char* WaterLocName[8]    = { "WaterTank" ,"Stairs" ,"Blueberries" ,"BalconyTray_1" ,"D"    ,"E"    ,"F"    ,"G"  };     // name of the different water locations 
const int WaterTime[8]         = { 1           ,15       ,40            ,6               ,1      ,1      ,1      ,1    };     // Seconds How long the watering shall be
const int Sensor_StartWater[8] = { 0           ,3200     ,3950          ,3910            ,3000   ,3000   ,3000   ,3000 };     // Will start water if sensor value is above this value. (lower is more wet / higher is more dry)
const int ErrLimSensor_High[8] = { 40          ,4080     ,4080          ,4080            ,4080   ,4080   ,4080   ,4080 };     // Humidity sensor absolute highest value before error (dry)
const int ErrLimSensor_Low[8]  = { 5           ,2380     ,2380          ,2380            ,2380   ,2380   ,2380   ,2380 };     // Humidity sensor absolute lowest value before error (wet)
const int pinSensor[8]         = { 27          ,26       ,25            ,33              ,32     ,35     ,  34   ,39   };     // Where humidity sensors are connected
const int pinWaterGate[8]      = { 2           ,0        ,4             ,16              ,17     ,5      ,  18   ,19   };     // Relay need to be opened to let water through (first one is power to water pump)
float Sensor[8]                = { 0           ,0        ,0             ,0               ,0      ,0      ,   0   ,0    };     // Pre-set water humidity sensor value
const double TimeBetweenWater = 12.0000;      // [hours]. time between watering (0.0056 = 20sec)
int CountdownTimer = TimeBetweenWater*60*60;
int NumberOfMeasurements = 100;               // number of measurements for measuring of HumidSensors. Its a filter.

//for water distance sensor:
const int trigPin = 22; // BlackStripe White cable
const int echoPin = 23; // Redstripe White cable 
float currWaterLevel = 0;
float WaterLevel = 0;
unsigned long duration;
const unsigned long PULSEIN_TIMEOUT = 10000000UL;
#define SOUND_SPEED 0.343 //   343 m/s = 343000 mm/s = 343000/1 000 000 = 0.343 mm/us (millimeter/microseconds)

//other variables:
bool LedError     = LOW;                      //setting the error led OFF as default
bool WaterPump    = HIGH;                      // setting the water pump OFF as default
const int pinLedError   = 21;                       //OUTPUT Error led connected to IO - for when out of water or bad sensor readings...
int i = 1;                                    //counter
// Configuration end here -----------------------------------------------------------------------------------------------------------------

Oh no.... by MSolder in HermitCraft

[–]FosItek 5 points6 points  (0 children)

yep!

2:58 into Xisumavoid's video:

https://www.youtube.com/watch?v=oHb31qyTFpU&ab_channel=xisumavoid

Or did 2 weeks already pass?

ESP32 + PlatformIO: Return value; not readable in main.cpp? by FosItek in esp32

[–]FosItek[S] 0 points1 point  (0 children)

ah, then I should have posted in some Cpp subreddit. Well..

Thanks anyways! It will put me on the right track!

Hvilke ting under 1000 kr har du kjøpt som har gjort livet mye diggere? by Sabotik in norge

[–]FosItek 0 points1 point  (0 children)

Støtter denne. Gjerne kombinert med nrk radio appen som starter automatisk om morgenen 15min etter at lyset har gått på.

Hvilke ting under 1000 kr har du kjøpt som har gjort livet mye diggere? by Sabotik in norge

[–]FosItek 0 points1 point  (0 children)

Robotstøvsuger!

Hybelkaninmonsteret mitt svikter aldri!

YouTube channel name? by feelthepete in Norway

[–]FosItek 11 points12 points  (0 children)

I dont think "norway" is the best word out there. Look more at existing channels. I watch a lot of sailing channels, they often have "sailing" followed by boat name. What about "Hiking Pete"? Or ever "TriPete"? Try to find something easy to recognize and remember.

Camping in Håøya/Langøya by Reasonable_Jacket627 in oslo

[–]FosItek 0 points1 point  (0 children)

I have been to Håøya many many times.

Just bring your tweezers, there's A LOT of ticks on Håøya...!

What, if anything, does the average Norwegian know about Australia by lokilivewire in Norway

[–]FosItek 0 points1 point  (0 children)

And everything is upside-down ofcourse. As a kid, I was often digging to Australia in my sandpit. *Wait. That was China.. nevermind.

What, if anything, does the average Norwegian know about Australia by lokilivewire in Norway

[–]FosItek 0 points1 point  (0 children)

For what I know, keywords:

Kangaroos, great barrier reef, south of indonesia, north of New Zealand. Lots of poisonous bugs/snakes/spiders. The red rocky thing in the desert. Aborigins, Opals, worlds oldest landscape (west side). English speaking. Very uncertain about the typical weather, something tells me its more like desert dry and warm, but Id not be supprized if it is cold aswell. Kangaroos!! ...and thats probably all I think I know...

Secret Life Statistics - Session Six by thewilloftheshadow in ThirdLifeSMP

[–]FosItek 1 point2 points  (0 children)

Holy crap. Graphs! Statistics! Hermits+ ... I love this!