# Microcontrollers

## Assignment

Create a compelling interaction between Max and the Sparkfun Digital Sandbox (Arduino). You must either send data to Max from the Arduino or send data from Max to the Arduino (or both!).

Places to begin:

* example Max files in Help > Reference or Help > Examples folder
* combine a preexisting Max patch with the serial patches I give you below

Demonstrate your project during class March 18 and share your Max patch and Arduino Sketch with the class.

## Sparkfun Digital Sandbox

{% hint style="warning" %}
We'll be writing Arduino code (text) rather than using the graphical programming language called ArduBlock.
{% endhint %}

## Setup

1. Install FTDI (USB) Drivers = <https://www.ftdichip.com/Drivers/VCP.htm>

   <img src="/files/-MJT4nQkOO6Smyq8nuT0" alt="" data-size="original">&#x20;
2. Install the Arduino IDE = <https://www.arduino.cc/en/Main/Software>
3. Install the Digital Sandbox board definitions = <https://learn.sparkfun.com/tutorials/installing-arduino-ide/board-add-ons-with-arduino-board-manager>

## Getting Started with the Sandbox Alone

<https://learn.sparkfun.com/tutorials/digital-sandbox-arduino-companion>

* start with 1. Exploring Blink
* then do 2. Multi-Blink
  * realize that 1. Exploring Blink should have run pinMode() in the setup() to declare D13 as OUTPUT ([see this article for more info](https://www.baldengineer.com/when-to-use-arduinos-pinmode-and-why.html))

```
void setup() {
  pinMode(13, OUTPUT);    // sets the digital pin 13 as output
}

void loop() {
  digitalWrite(13, HIGH); // sets the digital pin 13 on
  delay(1000);            // waits for a second
  digitalWrite(13, LOW);  // sets the digital pin 13 off
  delay(1000);            // waits for a second
}
```

* 16\. Servo Sweeper = make sure the "charge" switch on the Digital SandBox is in the "off" position

## Digital Sandbox + Max

How serial communication works = <https://learn.sparkfun.com/tutorials/serial-communication/all>&#x20;

Here's another helpful tutorial = <https://youtu.be/6bT3G4Mep7E>

#### Example files to download:

{% file src="/files/-MVXj9dpY07-HWamjLNw" %}

Hive 2.0 = <https://hopkinsduffield.com/2014/12/11/hive-2-0-documentation/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://benjohansen.gitbook.io/eacomp/old/course-schedule-spring2021-mus4203/microcontrollers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
