My daughter came home and told me that she needed to build a volcano for school. She said it did not even have to do anyhting, but she wanted to do something different. So began the Raspberry PI volcano. She said it was suppose to be on a 1ft x 1ft board. Her volcano is not the typical cone shape. It was flat so that made it different, but in the end I think it turned out nice.The teacher was impressed. My daughter learned some fun things and we had the coolest volcano in class. Plus other kids that did make theirs do something, it went to quick. As fast as they poired in the items it was over. We had enough soap and water to do a 10 minute plus show.
Here is the container that we used
Top view showing the copper nozzle
This is the final look with it working
Parts Needed |
|
Check out the video of the project!
You need to download the Visual Studio code here VolcanoVS. I have a preiew of the main part of the code below. I have a relay mounted to the Raspberry PI. The main reason for the relay is 5v on one side and 12v on the other. I have two buttons one that just makes it turn the relay on and off. The other button uses an array to do a sequence of on/off combinations.
using System; using Windows.Devices.Gpio; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Media; using System.Threading.Tasks; using System.Net.Http; namespace HomeIOT { public sealed partial class MainPage : Page { private const int RLY_PIN = 5; private int[] hl = new int[15] { 0,1,2,2,0,2,1,2,2,0,2,2,0,2,1 };// I use this to put the pump on off or pause private int c = 0; //just a count private GpioPin gpin; private GpioPinValue pinValue; private DispatcherTimer timer; public MainPage() { InitializeComponent(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(500); // Timer to do something every 500 mil timer.Tick += Timer_Tick; InitGPIO(); } private void InitGPIO() { var gpio = GpioController.GetDefault(); // Show an error if there is no GPIO controller if (gpio == null) { gpin = null; return; } gpin = gpio.OpenPin(RLY_PIN); pinValue = GpioPinValue.Low; gpin.Write(pinValue); gpin.SetDriveMode(GpioPinDriveMode.Output); } private void Timer_Tick(object sender, object e) { if (c == 15) //I put 15 items in the array above, so once it hits 15 start over { c = 0; } //check the case of hi at the count amount 0= High, 1 = Low , 2 keep the same as last time and wait switch (hl[c]) { case 0: c += 1; pinValue = GpioPinValue.High; gpin.Write(pinValue); gpin.SetDriveMode(GpioPinDriveMode.Output); break; case 1: pinValue = GpioPinValue.Low; gpin.Write(pinValue); gpin.SetDriveMode(GpioPinDriveMode.Output); c += 1; break; case 2: c += 1; break; } } private void OnOff_Checked(object sender, RoutedEventArgs e) { pinValue = GpioPinValue.High; gpin.Write(pinValue); gpin.SetDriveMode(GpioPinDriveMode.Output); } private void RunProgram_Checked(object sender, RoutedEventArgs e) { timer.Start(); } private void RunProgram_Unchecked(object sender, RoutedEventArgs e) { timer.Stop(); pinValue = GpioPinValue.Low; gpin.Write(pinValue); gpin.SetDriveMode(GpioPinDriveMode.Output); } private void OnOff_Unchecked(object sender, RoutedEventArgs e) { pinValue = GpioPinValue.Low; gpin.Write(pinValue); gpin.SetDriveMode(GpioPinDriveMode.Output); } } }