in this project the concept of electromagnet is defined using codes.
View this project in Scratch
Scratch