Arduino coding (telling it to turn a light off when 2 touch sensors are pressed):
void setup() {
// put your setup code here, to run once:
pinMode(11,OUTPUT);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int Sensor1 = analogRead(A0); // tells the Arduino that the thing (touch sensor) plugged into A0 is called "Sensor1", and to read it
int Sensor2 = analogRead(A1); // tells the Arduino that the thing (touch sensor) plugged into A1 is called "Sensor2", and to read it
if(Sensor1 < 200) { // if the touch sensor1 is not touched
digitalWrite(11,HIGH); // leave light on
} else if (Sensor1 > 200) { // if touch sensor1 is touched
}if (Sensor2 > 200){ // if touch sensor2 is touched as well
while (Sensor1 > 200){ //while sensor1 is touched too
digitalWrite (11, LOW); //turn the light off
}
}else { //if all that doesn't happen
digitalWrite (11, HIGH); // leave light on
}
}
Business plan pie chart coding:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 5 16:40:09 2016
@author: home
"""
# pandas, numpy, and matplotlib.pyplot are libraries (add-ons)
import pandas
import numpy as np
import matplotlib.pyplot as plt
#this code allows you to read the PythonU2P1 file and call it 'data'
#so that you will be able to access the file easier
data = pandas.read_csv("PythonU2P1.csv", low_memory=False)
#the following code allows Python to count the distribution of the responses
print("Response for Experience in the Tinkering Project")
response_exp = data["Code-General"].value_counts(sort=False)
print(response_exp)
print("Response (in %) for Experience in the Tinkering Project")
percent_exp = data["Code-General"].value_counts(sort=False, normalize=True)
#adding "normalize=True" allows Python to count the distribution of the responses
#and find the percentage
print(percent_exp)
#lines 30-40 create a pie chart
labels = 'Neutral', 'Positive' #labels of each section of pie chart
sizes = [0.43, 0.57] #percentages for each section of pie chart
colors = ['orange', 'blue'] #colours for each section of pie chart
plt.pie(sizes, labels=labels, colors=colors,
autopct='%1.1f%%', startangle=0)
plt.title(' ')
#set aspect ratio to be equal so that pie is drawn as a circle
plt.axis('equal')
plt.show()