Spikeling: A low-cost hardware implementation of a spiking neuron for neuroscience teaching and outreach

Understanding how neurons encode and compute information is fundamental to our study of the brain, but opportunities for hands-on experience with neurophysiological techniques on live neurons are scarce in science education. Here, we present Spikeling, an open source in silico implementation of a spiking neuron that costs £25 and mimics a wide range of neuronal behaviours for classroom education and public neuroscience outreach. Spikeling is based on an Arduino microcontroller running the computationally efficient Izhikevich model of a spiking neuron. The microcontroller is connected to input ports that simulate synaptic excitation or inhibition, to dials controlling current injection and noise levels, to a photodiode that makes Spikeling light sensitive, and to a light-emitting diode (LED) and speaker that allows spikes to be seen and heard. Output ports provide access to variables such as membrane potential for recording in experiments or digital signals that can be used to excite other connected Spikelings. These features allow for the intuitive exploration of the function of neurons and networks mimicking electrophysiological experiments. We also report our experience of using Spikeling as a teaching tool for undergraduate and graduate neuroscience education in Nigeria and the United Kingdom.


Introduction
Neuroscience is a major arm of modern life sciences. The first neuroscience degrees were awarded by the University of Sussex in 1972, and many universities worldwide are now offering dedicated neuroscience undergraduate degrees [1] [2]. A fundamental aspect of these courses is understanding electrical signalling within neurons and the transmission of signals across synapses [3] as well as the experimental techniques necessary to observe these properties [4]. However, owing to budgetary constraints and logistical hurdles, few students can be afforded the opportunity to experience an electrophysiological recording of a living neuron in action, e.g., during an experimental class. Similarly, public understanding about the fundamentals of brain function is hampered by the lack of cheap, approachable, and easy-to-use tools for neuroscience outreach aimed at illuminating how the basic machines of the brain, neurons, and synapses operate to represent information [5]. The growing public interest in areas such as artificial intelligence and the effects of neurodegeneration on an aging population make it more pressing than ever to foster public awareness and interest in basic concepts in neuroscience [6].
To support university-level neuroscience teaching and public understanding of neurons, we designed 'Spikeling' (Fig 1A), a £25 electronic circuit that mimics the electrical properties of spiking neurons by running the computationally efficient yet versatile Izhikevich model [7] in real time. Depending on settings, Spikeling executes at approximately 420-1,000 Hz, which is particularly appropriate to mimic 'slow' neurons of many invertebrates but about an order of magnitude slower than the fastest cortical neurons of mammals. The circuit is built around an Arduino [8], an open source programmable microcontroller that has found widespread use in the teaching of engineering and the design and implementation of open source laboratory hardware [9] [10].
Following the footsteps of Mahowald's and Douglas' 1991 first complete in silico realisation of a spiking neuron [11], Spikeling presents a simple yet powerful model of an excitable neuron with multiple dials and input/output options to play with. It is designed to facilitate a hands-on and intuitive approach to exploring the biophysics of neurons, their operation within neuronal networks, and the strategies by which they encode and process information. Spikeling can be excited and its activity recorded so as to design a variety of classical experiments similar to those that might be carried out on a biological neuron, which students learn about in textbooks [12] [13]. Here, we present a series of basic neuronal processes that are efficiently modelled using Spikeling, followed by an evaluation of our experience using the device for teaching senior undergraduate and Master's students in the UK and a graduate neuroscience summer school held in Nigeria. Spikeling should be a useful tool in educating students of neuroscience and psychology as well as students of engineering and computer science who are interested in the biophysics of neurons and brain function.

A simple hardware implementation of a spiking neuron
Spikeling (Fig 1) consists of an Arduino Nano microcontroller, a custom-printed circuit board, and a small number of standard electronic components (see Bill of Materials [BOM]). Assembly takes between 20 minutes and 2 hours, depending on previous experience with soldering and assembling circuit boards (see Spikeling manual). Spikeling features large contacts and ample component spacing to facilitate soldering for beginners. The functional properties of Spikeling can be modified by software within the Arduino integrated development environment (IDE).
Upon current injection, Spikeling begins to fire, with each spike translating into an audible 'click' from a speaker. In tandem, membrane potential is continuously tracked by the brightness of a light-emitting-diode (LED). To mimic different types of neurons, Spikeling features a 'mode button' for switching between different preprogrammed model behaviours (e.g., regular spiking, fast spiking, bursting, etc.). These can also be modified in the code provided.
For inputs, Spikeling ( Fig 1A, S1 Fig) has 3 Bayonet Neill-Concelman (BNC) ports. Two are 'input synapses' that each respond to 5-V transistor-transistor-logic (TTL) pulses (ports 1 and 2), such as the 'spike output' of a second unit. Thus, Spikelings can also be connected into simple neuronal networks (Fig 1B and 1C). A third BNC input connection (port 3) is an analog-in port that can be driven with a stand-alone stimulus generator or by a computer with a suitable output port. The gain and sign of all inputs can be continuously set with rotary encoder knobs (dials 1 and 2-with dial 2 controlling both analog-in and synapse 2 gain). One aim in the design of Spikeling was to also teach how neurons encode a sensory stimulus, so an on-board photodiode allows Spikeling to sense light. A light stimulus can be delivered externally (e.g., using a torch) or via an LED driven by a programmable on-board pulse generator. To mimic the 'noisiness' of biological neurons in intact neural circuits, a knob is provided to add variable amounts of membrane noise to the simulation (dial 3), while a final knob controls a static input current to set resting membrane voltage (dial 4).
For outputs, Spikeling features digital (port 4) and analog (port 5) BNC connections that can be used to visualise the 'membrane voltage' output on an external oscilloscope or to drive another Spikeling. Alternatively, the modelled membrane potential and several key internal processes (e.g., different current sources, input spikes, etc.) can be read out directly through the universal serial bus (USB)-based serial port into a computer for data logging and live display on a monitor (Fig 1B). We also provide Python (as Jupyter Notebook) and Matlab (Mathsworks) scripts for basic data visualisation and analysis. Finally, the system can be powered through the USB port or by a 9-V battery.

Simulating neuronal activity
In an informal setting, Spikeling can be explored in a playful manner simply by (i) depolarising or hyperpolarising the neuron via the input current (dial 4), (ii) dialling up the membrane noise (dial 3, Fig 2A), or (iii) manual stimulation of the photodiode with a torch (Fig 2B, S1 Video). In each case, elicited spike activity can be intuitively tracked by audible clicks coupled with flashes of the onboard LED. In parallel, membrane potential and input current can be tracked live on a personal computer screen through a serial plotter such as the openly available 'Serial oscilloscope' [14] ( Fig  1B). In this setup, Spikeling can be used to explore basic concepts in neuronal coding. For example, holding a torch over the photodiode initially elicits a burst of spikes that gradually slows down if the light is held in place, thereby mimicking a slowly adapting 'light-on' responsive neuron ( Fig  2B, left). The same experiment with Spikeling set to mode 2 (toggled via the on-board button) will reveal a rapidly adapting rebound burst of spikes upon removing the light, thereby mimicking a transient light-off responsive neuron (Fig 2B, center). Next, mode 3 mimics a sustained light-off driven neuron with an elevated basal spike rate ( Fig 2B, right, confer S2 Video). In total, Spikeling is preprogrammed with 5 modes (S2 Fig). These can easily be modified or extended by the user in the Arduino code provided.
For more formal experimentation, Spikeling can be driven in a temporally precise manner via the analog-in port or a regularly pulsed light source mounted over the photodiode (S3 Video). As a stimulus, port 1 (synapse 1/stimulus out) can be flexibly reconfigured into a digital stimulus generator. Alternatively, an external 0-5-V analog stimulus generator can be connected (not shown). At default settings, this port will continuously generate 0-5-V pulses at 50% duty cycle, with the stimulation rate being controlled through dial 1. Accordingly, simply connecting port 1 (stimulus out) to port 3 (analog-in) allows for temporally precise stimulation of the model neuron.
The millisecond precision achieved in this way can then be exploited to study neuronal function in further detail. For example, at default settings (see Spikeling manual) the stimulator directly coupled to the analog-in port drives a highly stereotyped spike train upon repeated stimulation (Fig 3A, left), as further elaborated in the raster plot ( Fig 3A, right, see also S2 Fig). From here, systematic variation of the analog-in gain (dial 2) can be used to drive Spikeling with different amplitude current steps, e.g., to build amplitude tuning functions for spike rate, latency, or first-spike time precision ( Fig 3B).
Next, rather than delivering port 1's square-pulse drive via analog-in, the user can instead drive an LED from the same port. In this way, positioning the LED above the photodiode (e.g., via the 3D-printable adapter provided or a custom paper tube) allows for temporally precise driving of Spikeling via light ( Fig 3C). Adding noise to this simulation allows exploring how the addition of noise initially distorts spike timings before affecting rates ( Fig 3D).
Similarly, the experimenter could vary the rate of stimulation to probe the intrinsic frequency tuning of a neuron (dial 1, not shown). At faster stimulus rates, Spikeling can be set to occasionally 'miss' individual current steps and instead adopt a volley code [15] for event timing ( Fig 4A). In this configuration, Spikeling continues to phase lock to the stimulus, as summarised in the event-aligned plot to the right. Note that even though spikes frequently fail, the subthreshold potential continues to reliably track the stimulus. From here, the static input current (dial 4) and noise (dial 3) can be tweaked to put the system into stochastic resonance [16] [17]. In this situation, counterintuitively, the addition of noise is beneficial to the code (Fig  4B). In the example shown, the 'generator potential' (the noise-free stimulus-driven membrane voltage fluctuations) is itself insufficient to elicit any spikes. As a result, the neuron fails to encode the stimulus at the level of its spike output (Fig 4B, left). Addition of noise occasionally takes the membrane potential above spike threshold (Fig 4B, middle), and the probability of this threshold crossing is higher during a depolarising phase of the generator. As a result, the system now elicits spikes, which, depending on the noise level chosen, reliably phase locks to the stimulus (Fig 4B, right). Such stochastic resonance can be used, e.g., by sensory systems As (A, right), with varying input gain to probe amplitude tuning. Note systematic effects on spike number, rate, time latency, and time precision. C. As (A), but this time driving Spikeling via an LED attached to the stimulus port stimulating the photodiode. Note different waveforms of input current and consequences on the elicited spike pattern compared to (A). D. As (C), with addition of current noise (dial 3). Note distortion of spike timings, while the number of spikes triggered remains approximately constant. LED, light-emitting diode.
Next, two or more Spikelings can be connected into a network via BNC cables (S4 Video). For this, the digital-out connector (port 4) of one unit is connected to one of two 'synapse-in' connectors (e.g., port 2) on another unit. Synaptic gain can then be controlled using a rotary encoder (here, dial 2) to vary the efficacy and sign of the coupling, thus mimicking excitatory or inhibitory connections (Fig 5A). Two reciprocally connected units can then be used to set up a basic central pattern generator [20] [21] (Fig 5B).
Spikeling can also be used to explore neuronal function more systematically, e.g., by estimating the linear filter that underlies its photo response in a given mode [22]. This is a fundamental approach in computational and sensory neuroscience, and the calculation of the linear filter is based on recording a neuron's response to a 'noise stimulus' for several minutes. Subsequent reverse correlation of the elicited spike or subthreshold activity against the original stimulus then allows for calculating the average stimulus that drove a response in the neuron: the linear filter, sometimes also referred to as 'time-reversed impulse response' or 'response kernel'. Reverse correlation to spikes is the more common calculation, when the linear filter is also termed the 'spike-triggered average' (STA) [23]. To explore this concept, Spikeling's stimulus port (1) can be set to generate binary noise at a chosen frequency via a flag in the Arduino code (see Spikeling manual). In this configuration, the photodiode can be stimulated by this noise stimulus via an LED as before (Fig 6A, confer Fig 3C), thereby driving spikes and subthreshold oscillations. The linear filters of a mode 1 Spikeling ('slow') reveal a clear biphasic (band pass) stimulus dependence at the level of spikes but a monophasic dependence (low pass) at the level of subthreshold activity (Fig 6B, black). In comparison, the same mode 1 neuron retuned to use a rapidly adapting photodiode-driven current ('fast') gives a triphasic stimulus dependence at the level of spikes and a biphasic dependence at the level of the subthreshold generator (Fig 6B, red).
Taken together, Spikeling can be used in a variety of classroom and demonstration scenarios, ranging from simple observations of changes in spike rates upon stimulation to advanced concepts in neuronal computation and analysis.
An example set of Spikeling-based classroom exercises is provided (see Spikeling manual). From here, advanced users can easily reprogramme the Arduino code to implement or fine tune further functionalities as required. The entire project, including all code, hardware design, BOMs, and detailed build instructions are available online for anyone to freely view and modify (https://github.com/BadenLab/Spikeling and https://badenlab.org/resources/).

Spikeling in the classroom
We evaluated the utility of Spikeling in two classroom scenarios: (i) as a 2-day section within a 3-week intensive neuroscience summer school held at Gombe State University, Nigeria by TReND in Africa [24] and (ii) as part of an 18-lecture module on 'Sensory function and computation' delivered to third year undergraduate and MSc neuroscience students at the University of Sussex, UK. We report on each experience in turn.
At Gombe State University, Nigeria, we ran two identical 2-day sessions for a total of 18 Africa-based biomedical graduate students (9 at a time) as part of the seventh TReND/ International Society of Neurochemistry (ISN) school on Insect Neuroscience and Drosophila Neurogenetics [24]. None of the students had much experience with neuronal computation or electrophysiological techniques, although most had covered basic concepts in neuroscience such as action potential generation in their undergraduate degrees. We introduced Spikeling in three steps. First, we held a 1-hour lecture during which a single Spikeling was connected to a computer with the serial oscilloscope output being projected live to the wall. In parallel, a whiteboard was used for explanations and discussions. From here, we combined a general explanation of concepts in neuronal computation on the board (e.g., rate versus time coding, subthreshold integration, phase locking etc.) and then demonstrated each phenomenon in front of the class using Spikeling. Based on feedback after the class, this was perceived as a very engaging and effective method for introducing concepts in neuronal coding. Next, we moved on to assembling Spikelings from bags of precompiled parts (Fig 7A and 7B). For this, every student was provided with the printed circuit board, the electronic components, and a soldering iron and taken through the assembly process by two instructors. After 2-3 hours, every student had successfully assembled a working unit, despite most not having had any experience with soldering or electronic circuit logic. In a third step, each student was then provided with the serial oscilloscope software as well as the exercise document and asked to sequentially work through a set of predesigned exercises (Fig 7C and 7D, see Spikeling manual) in their own time, with faculty being available to help as required. Following the course, all students kept their Spikeling to facilitate their own teaching at their host institutions in 7 different African countries (Nigeria, Malawi, Sudan, Egypt, Kenya, Zambia, and Burkina Faso).
At the University of Sussex, UK, we introduced preassembled Spikelings as part of 3 sets of 3-hour workshops provided to students in groups of 13. For this, we used a PC lab where each student had their own Spikeling and PC with Arduino, Serial Oscilloscope, and Matlab preinstalled (Fig 7E and 7F). The first session began with a 20-minute presentation of basic concepts in neuronal modelling and electronics, followed by a conceptual comparison between the biophysically realistic yet computationally heavy Hodgkin Huxley model [25], [26] and the much lighter phenomenological Izhikevich model [7] implemented in Spikeling. Next, we projected the serial oscilloscope screen of a Spikeling connected to the lecturer's laptop to the wall. This allowed easy, live demonstrations of some Spikeling functions, such as the photo response or the use of different modes. From here, we asked students to connect and set up their own units on their PCs and to start exploring 'how to best drive spikes' using their mobile phone torches. A. Via the Arduino code, the stimulus port can be set to deliver 50 Hz binary noise, here used to drive the photodiode via an LED (confer Fig 3C). Current and spike pattern elicited by this stimulus. B. Linear filters of a slow (black) and a fast (red) photo-adapting mode 1 neuron estimated at the level of spikes (left) and subthreshold membrane potential (right). LED, light-emitting diode.  Students quickly realised that simply holding the light above the photodiode ceases to be effective after a few hundred milliseconds, while repeatedly moving the light over the photodiode reliably elicits bursts of spikes. In this way, students could intuitively explore basic concepts in time coding.
Afterwards, we brought everyone back to the same page by demonstrating these key ideas on the Spikeling output projected onto the wall. We then showed students how to use the stimulator, what the dials do, and how to log data on the serial oscilloscope. We also showed them how to load and display their data using prewritten Matlab routines (see Supporting information, which also provides analogous Python routines). From this point, we asked students to carry out their first 'experiment' quantifying a neuron's tuning using 2 measures of response amplitude, instantaneous spike rate, and first-spike latency. These 2 tuning curves were compared, again followed by an in-class demonstration and discussion. In this way, we moved through the majority of Spikeling functions described in this paper over the course of 3 workshops.
Taken together, Spikeling allowed students to explore a number of fundamental aspects in sensory neuroscience, including analog and digital coding, detection of signals above noise, the functional consequences of adaptation, and the variety of temporal filters that neurons implement. The concepts acquired, as tested with take-home problem sets, dovetailed with lecture content covering rate and time coding, feature selectivity and tuning diversity, and adaptation. Students reported that the Spikeling work helped them to develop a more intuitive grasp of these central ideas in sensory and systems neuroscience.

Discussion
With modern systems of neuroscience increasingly moving into the area of big data for which the activity of thousands of neurons can be routinely recorded across a wide range of neuronal circuits [27][28][29][30][31][32][33], a deep understanding of how neurons encode and compute information is fundamental. These concepts need to be taught not just to students of the biological sciences but also to students of psychology as well as engineers and computer scientists interested in theoretical and computational neuroscience, artificial intelligence, and robotics [4]. However, concepts in neuronal coding and computation can be unintuitive to grasp or 'dry' in lectures, while classroom electrophysiology on live biological specimens can be technically challenging and costly to set up [3]. As a result, many students in these disciplines graduate without ever having had the opportunity to experience and control neuronal activity in hands-on experiments. Indeed, in many parts of the world, systems of neuroscience are only a rather peripheral aspect of neuroscience curricula, if present at all, while the cross-over of neuroscience into engineering and informatics often jumps immediately into discussions of networks based on units that are greatly simplified versions of biological neurons.
Spikeling is intended to help ameliorate some of these issues by allowing students to carry out experiments in the same general fashion as classical electrophysiologists but without the amplifiers, filters, manipulators, stimulus generators, and other equipment normally required. Its low cost makes it widely affordable, and once assembled, it can be used for teaching for many years without additional investment. It should also be immediately approachable to students of engineering and informatics who can explore the electrical properties of neurons and the code used to model these as well as carry out experiments illustrating basic concepts in theoretical and computational neuroscience [23]. By allowing students to interact physically with the device, e.g., by providing actual sensory inputs, Spikeling can help build an intuitive grasp of neuronal computations beyond that provided by pure computer simulation of neurons.
Other recent efforts have also recognised the need for more intuitive hardware models of spiking neurons, most notably the Neurotinker initiative [34], who release NeuroBytes. These come in a variety of neuron types, such as photoreceptors or motorneurons, and run a simple integrate-and-fire type model. Generally, NeuroBytes are designed to be very easy to use and to be connected in larger networks to teach neuronal control logic to children in a playful manner, albeit at the trade-off of giving less user control over model behaviour and data logging. In contrast, Spikeling is perhaps more suitable for undergraduate-level neuroscience education. Another initiative aiming to build microcontroller-based neurons is Spikee [35]. Finally, others have implemented the Izhikevich model on more powerful processors such as a Programmable-Intelligent-Computer-32 (PIC32) [36] or a field-programmable gate array (FPGA) [37]; however, these more expensive and complex implementations are, at least currently, more aimed at professionals in computing and electronic engineering and do not come with a dedicated lay and user-friendly interface. Notwithstanding, there are already many software-only implementations of neuron models available online for both research and teaching, including several that are free and open source. For example, NEURON [38] is a popular highend neuron simulator environment used primarily in research, while simulator for neural networks and action potentials (SNNAP) [39] and MetaNeuron [40] are but two of many examples of educational options.
With time, we hope that others may take up our basic design and build upon it, e.g., by providing inputs to other sensory modalities such as touch or sound or by changing the Arduino code to implement new functions or simulate neurons with different tuning properties. Spikeling could also be used as a 'test-neuron' in conjunction with existing electrophysiological equipment, e.g., to quickly verify stimulus protocols or as a stimulus generator.
Another point for future improvements is the model refresh rate. In the current 'standard' setup with all options enabled, the model runs at approximately 420 Hz. While this is easily sufficient to model basic conceptual processes of neuronal function, it is slower than what might be expected from, e.g., a mammalian cortical neuron and instead rather resembles neurons of cold-blooded species. If desired, we elaborate how the user can trade-off model complexity for speed (see Spikeling manual).
Notably, we are currently working on a version 2.0 of Spikeling, which uses the more powerful and WiFi-capable ESP8266 instead of the Arduino Nano. This version can either execute the model at about 5 to 10 times the speed of the version presented here, or alternatively drive a standalone colour thin film transistor (TFT) screen at approximately the same speed as the Arduino Nano (without screen). For Spikeling 2.0, please refer to the GitHub, which is updated on an ongoing basis.
Spikeling is available on a share-alike open license, prompting any modifications of the original code to be freely distributed for everyone to use. We aim to keep these efforts centralised on the Spikeling GitHub (https://github.com/BadenLab/Spikeling) or link to new repositories as they arise to gradually build a community of users and contributors. For convenience, we also setup a simplified component sourcing option Kitspace at https://kitspace.org/boards/ github.com/badenlab/spikeling/. All hardware instructions, code, manuals, and example data are freely available at https://github.com/BadenLab/Spikeling and https://badenlab.org/ resources/.