## Introduction: Linear Hall Sensor--For CubeSat

This was a group project for our classroom at school. Our names of the group are Logan, Caleb, and Jevin: and our team name was Golden Comics Inc..We are simulating a research flight to Mars to test for the magnetic field of Mars. We used a linear hall sensor and sd card holder hooked-up to our elegoo board to record the field. This Instructable is based off of NASA's cubesats. Cubesats are small 100mm x 100mm x 100mm picosatellites that weigh under 1.330 kg. Cubesats are flown on pre-planned rocket flights for specific ranges of research. Our cubesat is going to hold the arduino board, battery, wires, and sensor. More information about cubesats are at the NASA website here: https://www.nasa.gov/mission_pages/cubesats/overv...

## Step 2: Building a CubeSat

For the cube that we put the Arduino in itself, we 3-D printed the cuesat. If you are unable to get a printer, you can make your own out of anything you can find such as legos, popsicle sticks, or metal frames.

## Step 3: Wiring the Linear Hall Sensor

• Yellow Wire From A0 to A0 on Linear Hall Sensor
• Red Wire From GND to G on Linear Hall Sensor
• Orange Wire From 5V to + on Linear Hall Sensor
• Brown Wire from 4 to D0 on Linear Hall Sensor

## Step 4: Coding the Linear Hall Sensor

```int led = 13 ; // LED on arduinoint digitalPin = 3; // linear Hall magnetic sensor digital interface
int analogPin = A0; // linear Hall magnetic sensor analog interface
int digitalVal ; // digital readings
int analogVal; // analog readings
void setup ()
{
pinMode (led, OUTPUT);
pinMode (digitalPin, INPUT);
//pinMode(analogPin, INPUT);
Serial.begin(9600);
}
void loop ()
{
// Read the digital interface
digitalVal = digitalRead(digitalPin) ;
if (digitalVal == HIGH) // When magnetic field is present, Arduino LED is on
{
digitalWrite (led, HIGH);
}
else
{
digitalWrite (led, LOW);
}

Serial.println(analogVal); // print analog value

}```

## Step 5: Wiring the SD Card Adapter to the Linear Hall Sensor

• Yellow Wire From A0 to A0 on Linear Hall Sensor
• Red Wire From GND to G on Linear Hall Sensor
• Orange Wire From 5V to + on Linear Hall Sensor
• Brown Wire from 4 to D0 on Linear Hall Sensor
• Green Wire From GND to GND on Micro SD Card Memory Shield
• Blue Wire From Red Wire on Linear Hall Sensor to VCC on Micro SD Card Memory Shield (Remember the Red Wires is 5V so since we don't have another 5V for the SD Card Memory Shield that is why we are connecting the blue wire from the Red Wire to the VCC to make things easier)
• Purple Wire From 12 to MISO on Micro SD Card Memory Shield
• Grey Wire From ~11 to MOSI on Micro SD Card Memory Shield
• Light Green Wire From 13 to SCK on Micro SD Card Memory Shield
• Black Wire from ~10 to CS on Micro SD Card Memory Shield

## Step 6: Coding the SD Card Adapter to the Linear Hall Sensor

```#include <Wire.h>
#include <SD.h>
#include <SPI.h>
File LinearData;  //name of file
float magnetic; //variable to hold data
int led = 13 ; // LED on arduino
int digitalPin = 3; // linear Hall magnetic sensor digital interface
int analogPin = A0; // linear Hall magnetic sensor analog interface
int digitalVal ; // digital readings
int analogVal; // analog readings
void setup() {
pinMode (10, OUTPUT); //must set pin 10 to output
pinMode (7, OUTPUT); //for LED, which is optionable. we didn't use one, so data collection doesn't get effected by this.
SD.begin (4); // this is to begin collecting and transfering data to the SD card
{
pinMode (led, OUTPUT);
pinMode (digitalPin, INPUT);
//pinMode(analogPin, INPUT);
Serial.begin(9600);
}
}
void loop() {
LinearData = SD.open ("log.txt", FILE_WRITE);
if (LinearData) {

Serial.print("Magnetic = "); // Prints the data collected to the serial monitor
Serial.print(magnetic);
Serial.print(" Gs");   // Gs is the abbreviation of the variable Gauss
Serial.println(analogVal); // print analog value
LinearData.println(analogVal); // this is to print the data to the file created above

digitalWrite(7, HIGH);
delay(500);
digitalWrite(7, LOW);
delay(500);
LinearData.close();

}
{
// Read the digital interface
digitalVal = digitalRead(digitalPin) ;
if (digitalVal == HIGH) // When magnetic field is present, Arduino LED is on
{
digitalWrite (led, HIGH);
}
else
{
digitalWrite (led, LOW);
}