Cleanflight on STM32?

Hi EJbuilder,

I looked at my files on stm32 drones and realized they were very similar to the video you posted the link to. I have a couple of stm32 chips:

Do you want to try and put Cleanflight on this chip?

See you Saturday,

Bob

Accelerologger: error opening test.txt problem!!!

Now I have solved my silly mistake I have run into another problem!!!

I looked in the serial monitor and I am getting the:

error opening test.txt

Part of the code being carried out! Here is a Fritzing diagram of the Accelerologger:

The diagram is a bit messy but it’ll do to show the circuit config. I ran the default SD Card Reader code on it:

#include <SD.h>
#include <SPI.h>

File myFile;

int pinCS = 10;

void setup() {

Serial.begin(9600);
pinMode(pinCS, OUTPUT);

// SD Card Initialization
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}

// Create/Open file
myFile = SD.open("test.txt", FILE_WRITE);

// if the file opened okay, write to it:
if (myFile) {
Serial.println("Writing to file...");
// Write to file
myFile.println("Testing text 1, 2 ,3...");
myFile.close(); // close the file
Serial.println("Done.");
}
// if the file didn't open, print an error:
else {
Serial.println("error opening test.txt");
}

// Reading the file
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("Read:");
// Reading the whole file
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
}
else {
Serial.println("error opening test.txt");
}

}
void loop() {
// empty
}

With this code, it worked perfectly. Here is the response received in the serial monitor:

SD card is ready to use.
Writing to file…
Done.
Read:
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…

Geez!!! all these problems! I hope I eventually get to the bottom of them all!

Thanks for everyone’s help!

EJBuilder

test

In this tutorial, you will learn how to program your robot to come to you when you call it, and do a happy dance when you pat it!

In this task you will learn about working with the ultrasonic and touch sensors.

Note: As with last week, you will need to do some building for this challenge, but the emphasis is on programming!

The challenge

The idea for the tutorial is to create a robot that comes to you when you “call” it, and do a happy dance when you pat it!

1. Tutorial

2. Try it for yourself

Once you’ve watched the tutorial, have a go at creating your own version of this program that incorporates the two sample programs shown in the video.

Note: The EV3 kit doesn’t include a sound sensor, so in this tutorial we use the ultrasound sensor to call the robot by waving at it. If, however, you’ve got access to an old sound sensor, you’re welcome to try using that instead.

3. Share it!

Finally, create an entry for your team journal describing what you tried, including what worked and what didn’t.

If you’ve got something cool to share, then please take a screenshot of your program and add it to your team journal (use the Add Media button at the top of the screen when you’re editing your post).

 

Next: TLC

 

Accelerologger: More Problems With New Code!!!

This is now solved!!! Check it out what a silly mistake! NO VOID SETUP!!!!!!

Here is the new code:

#include <SparkFun_ADXL345.h>

#include <SD.h>
#include <SPI.h>

//ADXL345 adxl = ADXL345(10); For SPI Cumunication
ADXL345 adxl = ADXL345();
File myFile;
const int threshold = 1499;
const int switchPin = 7;
int switchState;
int ctr = 0;
int pinCS = 10;
int x,y,z;
int sumX, sumY, sumZ;

void loop() {
//define int x, y, z in setup instead
// also define int sumX, sumY, sumZ in setup
adxl.readAccel(&x, &y, &z);
sumX += x;
sumY += y;
sumZ += z;

switchState = digitalRead(switchPin);

if (switchState == HIGH) {
ctr++;
if (ctr > threshold) {
if (myFile) {
myFile.println(sumY/threshold);
Serial.println(sumY/threshold);
}
else {
Serial.println("error opening test.txt");
}
sumX = 0;
sumY = 0;
sumZ = 0;
ctr = 0;
}

} else //switchState != HIGH
{
myFile.close();
Serial.println("closed");
}
}

But I am having another problem it doesn’t upload it comes up with the error:

Arduino: 1.8.3 (Windows 10), Board: “Arduino Nano, ATmega328”

C:\Users\ETHANJ~1\AppData\Local\Temp\cclGBXne.ltrans1.ltrans.o: In function `main’:

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup’

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Nano.

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

I hope we can figure out what is wrong!

EJBuilder

(P.S much thanks to Mike’s help!!!)

Accelerologger (Accelerometer Datalogger): Help needed with code!

Hi Everyone, For the scientific investigation awards I have been designing an accelerologger device that reads the speed of Its movement. So far I have constructed the hardware.

It consists of an Arduino Nano, an ADXL 3 axis gyro/accelerometer  and a Micro SD Card Reader . So far I have got each device (accelerometer/gyro + datalogger module) working succesfully and now have been trying to combine the code. Here is what I have done so far:

 

#include <SparkFun_ADXL345.h>
#include <SD.h>
#include <SPI.h>

//ADXL345 adxl = ADXL345(10); For SPI Cumunication
ADXL345 adxl = ADXL345();
File myFile;
const int threshold = 1499;
const int switchPin = 7;
int switchState;
int ctr = 0;
int pinCS = 10;


void setup() {
Serial.begin(9600);
Serial.println();
pinMode(pinCS, OUTPUT);
pinMode(switchPin, OUTPUT);

adxl.powerOn();

adxl.setRangeSetting(16);

adxl.setSpiBit(0);

if (SD.begin())
{
Serial.println(“SD card is ready…”);
} else
{
Serial.println(“SD card initialization failed”);
return;
}

// create and open a file
myFile = SD.open(“testRun.txt”, FILE_WRITE);
}

void loop() {
int x, y, z;
adxl.readAccel(&x, &y, &z);
switchState = digitalRead(switchPin);

if (switchState == HIGH) {
ctr++;
if (ctr > threshold) {
if (myFile) {
myFile.println(y);
Serial.println(y);
}
// if the file didn’t open, print an error:
else {
Serial.println(“error opening test.txt”);
}
}
ctr = 0;
} else
{
myFile.close();
Serial.println(“closed”);
}
}

That is it. It all most works perfectly. The only issues I am facing is that none of the accelerometer details are serially printed or written on the SD card in a text file. If anyone can help please take a look at the code and do.

 

EJBuilder